MomentJS - 長日期格式



此方法有助於自定義區域設定的長日期格式。

語法

moment.updateLocale('en', {
   longDateFormat : Object
});

此處 longDateFormat 是包含與每種格式相對應的鍵值對的物件。

示例

var localeData = moment.updateLocale('fr', {
   longDateFormat: {
      LT: "h:mm",
      LTS: "h:mm:ss A",
      L: "MM/DD/YYYY",
      l: "M/D/YYYY",
      LL: "MMMM Do YYYY",
      ll: "MMM D YYYY",
      LLL: "MMMM Do YYYY LT",
      lll: "MMM D YYYY LT",
      LLLL: "dddd, MMMM Do YYYY LT",
      llll: "ddd, MMM D YYYY LT"
   }
});
var m = moment().format('LT');
var x = moment().format('LLLL');

輸出

Long
momentjs_customization.htm
廣告
© . All rights reserved.