MomentJS - Checking current locale


Advertisements

We can check the current locale using moment.locale().

Syntax

moment.locale();

Example

moment.locale('fr');
var k = moment.locale();

Output

Current

Example

moment.locale('fr');
var k = moment.locale();
moment.locale('ja');
var s = moment.locale();

Output

Current Locale

moment.locales() gives the list of all the locales available for use or which are loaded. Observe the following line of code and its output −

moment.locales()

Output

Moment Locales

In the above example, we are using thelocale.min.js with all locales, so moment.locales() displays all the locales as shown above.

momentjs_internationalization.htm
Advertisements