Locale detection with Moment.js

后端 未结 1 1456
既然无缘
既然无缘 2020-12-01 01:30

I am using Moment.js in my project and formatting dates as follows:

var date = moment.unix(1318781876);
return date.format(\'LLLL\');

The m

相关标签:
1条回答
  • 2020-12-01 02:28

    As of momentjs documentation:

    By default, Moment.js comes with English locale strings. If you need other locales, you can load them into Moment.js for later use.

    You can change it with that:

    moment.locale(locale);
    

    To get the user's locale with javascript you can do that:

    var locale = window.navigator.userLanguage || window.navigator.language;
    

    Refer to: http://momentjs.com/docs/#/i18n/changing-locale/

    and JavaScript for detecting browser language preference

    0 讨论(0)
提交回复
热议问题