小编Jek*_*yll的帖子

使用Moment.js的区域设置和特定日期格式

我在我的项目和格式化日期中使用Moment.js如下:

var locale = window.navigator.userLanguage || window.navigator.language;
moment.locale(locale);
someDate.format("L");
Run Code Online (Sandbox Code Playgroud)

它运作良好但有时我需要显示没有年份的日期.我不能使用类似的东西,someDate.format("MM/DD")因为在某些语言中它应该是someDate.format("DD/MM").我需要一些想法,L,LL,LLL但没有一年.

我能做什么?

LTS : 'h:mm:ss A',
LT : 'h:mm A',
L : 'MM/DD/YYYY',
LL : 'MMMM D, YYYY',
LLL : 'MMMM D, YYYY LT',
LLLL : 'dddd, MMMM D, YYYY LT'
Run Code Online (Sandbox Code Playgroud)

javascript locale localization momentjs

37
推荐指数
2
解决办法
3万
查看次数

标签 统计

javascript ×1

locale ×1

localization ×1

momentjs ×1