MomentJS - Relative Time



This method helps in obtaining the relative time.

Syntax

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

Example

var localeData = moment.updateLocale('en', {
   relativeTime: {
      future: "in %s",
      past: "%s ago",
      s: 'hello, a few seconds',
      ss: '%d seconds',
      m: "a minute",
      mm: "%d minutes",
      h: "an hour",
      hh: "%d hours",
      d: "a day",
      dd: "%d days",
      M: "a month",
      MM: "%d months",
      y: "a year",
      yy: "%d years"
   }
});
var m = moment().fromNow();

Output

Relative
momentjs_customization.htm
Advertisements