0
从文档设置格式l
返回格式为“M/D/YYYY”。 有没有办法根据区域设置只取得D/M
或M/D
格式的日期?这是我现在的代码。时刻格式化区域设置
var locale = window.navigator.userLanguage || window.navigator.language;
moment.locale(locale);
var momentTime = moment(d);
console.log(momentTime.format('l'));
例如如果语言环境是French
那么日期应该在D/M
格式返回,如果语言环境是english-us
然后将日期应在M/D
格式自动返回。
[区域设置和特定的日期格式Moment.js](的可能的复制https://stackoverflow.com/questions/27360102/locale-and-specific-date-format-with -moment-JS) – SubjectDelta