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