首页 > 解决方案 > 如何将月份名称英语更改为阿拉伯语

问题描述

在我的 codepen 链接下方,我有事件日历,它直接获取英文月份,但我想将其月份名称更改为阿拉伯语

例如:二月需要更改为“فبراير”

Codepen 链接:点击这里

$('.b-calendar__header .month').each(function() {
    var text = $(this).text();
    $(this).text(text.replace('February', 'فبراير')); 
});

我试过这种方式但不工作

请帮忙

标签: javascriptjquerycss

解决方案


我希望这对你有用

const formatter = new Intl.DateTimeFormat('ar', { month: 'short' });
const month1 = formatter.format(new Date());
console.log(month1);


推荐阅读