MomentJS - Global locale



We can assign locale globally and all the date /time details will be available in the locale assigned.

Syntax

moment.locale(String);
moment.locale(String[]);
moment.locale(String, Object);

Example

moment.locale("hi");
var a = moment.duration(1, 'days').humanize();
var b = moment.duration(1, 'week').humanize();

Output

Global

Example

moment.locale("hi");
var a = moment().fromNow();

Output

Global Locale

Example

moment.locale("pt");
var a = moment().locale();

Output

Moment Locale
momentjs_internationalization.htm
Advertisements