I need to show date in localized format, so I used
moment().format('l');
function of Moment JS https://momentjs.com/#multiple-locale-support
It is not working as expected in different systems/browsers
root cause of the issue is that Moment reads current locale as "en" even when the environment is France ("fr")
console.log('moment lang: '+moment.lang());
console.log('userLanguage: '+window.navigator.userLanguage);
console.log('language: '+window.navigator.language);
Results produced:
moment lang: en
userLanguage: fr-FR
language: fr-FR
Moment will give correct locale formatted date if I explicitly set
moment().locale(window.navigator.userLanguage||window.navigator.language);
Do I really need to explicitly set locale in Moment or I am doing something wrong?
A note for duplicate question issue: question is how does Momentjs reads locale.