How to change the locale in moment.js?

Member

by rollin , in category: Javascript , 4 months ago

How to change the locale in moment.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aniya.jaskolski , 4 months ago

@rollin 

To change the locale in moment.js, you can use the locale() method. Here's an example of how you can change the locale to French:

1
moment.locale('fr');


You can replace 'fr' with the locale code of the language you want to use. You can find a list of supported locales on the moment.js website.


After changing the locale, all date and time formatting will be based on the new locale.