我在react-datepicker用例中针对此问题的解决方法是以cyrilic作为格式传递月份名称。
const getMonthName = (date) => {
const months = ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'];
return months[date.getMonth()];
};
<DatePicker dateFormatCalendar={ getMonthName(new Date()) } />
format(new Date(2014,1,11),getMonthName(new Date(2014,11)))
在我的有限用例下工作
,
您需要将 MMMM 更改为 LLLL
,
使用 LLLL
,如 date-fns format documentation page 处的示例所示。
演示:
const fns = require('date-fns');
const { ru } = require('date-fns/locale');
const now = new Date(2019,11,1);
console.log(fns.format(now,"LLLL",{locale: ru}));
输出:
декабрь
ONLINE DEMO
(注意:点击在线演示页面右下角的 Console
。)
本文链接:https://www.f2er.com/3020559.html