MomentJS - Long Date Formats


Advertisements

This method helps in customizing longdateformat for a locale.

Syntax

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

Here longDateFormat is an object containing key / value pair for each format.

Example

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');

Output

Long
momentjs_customization.htm
Advertisements