MomentJS - Locale


Advertisements

This method helps to get/set the duration using locale. When used with humanize, you will see the difference in output for locale() method.

Syntax

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

Example

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

Output

Locales
momentjs_durations.htm
Advertisements