MomentJS - Changing Locale Locally



We need locale to applied locally in case we need to handle many locales in an application.

Here is a way to work with locale locally.

Syntax

moment().locale(String|Boolean);

Example

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

Output

Changing

Example

moment.locale("pt");
var a = moment().format('LLLL');
moment.locale("hi");
var b = moment().format('LLLL');

Output

Changing Locale
momentjs_internationalization.htm
Advertisements