MomentJS - 語言環境



此方法有助於使用語言環境獲取/設定持續時間。與 humanize 一起使用時,您會看到 locale() 方法的輸出差異。

語法

moment.duration().locale();
moment.duration().locale(String);

示例

var hi = moment.duration(1, "day").locale("hi").humanize();
var en = moment.duration(1, "minutes").locale("en").humanize();
var ja = moment.duration(1, "seconds").locale("ja").humanize();
var it = moment.duration(1, "hours").locale("it").humanize();
var marathi = moment.duration(1, "day").locale("mr").humanize();
var konkani = moment.duration(1, "day").locale("gom-latn").humanize();
var kn = moment.duration(1, "day").locale("kn").humanize();

輸出

Locales
momentjs_durations.htm
廣告