Getting localized day of week

前端 未结 2 1987
无人及你
无人及你 2021-02-05 14:17

I\'d like to get the names of the days of the weeks in JavaScript, localized to the user\'s current language; preferably with something a bit nicer than what I\'m using now:

相关标签:
2条回答
  • 2021-02-05 14:35

    Take a look at datejs, it handles localization very nicely. It comes with a lot of globalization setups. You just load the globalization setup of your current CultureInfo and datejs takes care of the rest.

    Javascript Date Localization

    0 讨论(0)
  • 2021-02-05 14:51

    I use Date.toLocaleString(), for example:

    d = new Date();
    d.toLocaleString(window.navigator.language, {weekday: 'long'});
    

    or

    d.toLocaleString('sk-SK', {weekday: 'short'});
    
    0 讨论(0)
提交回复
热议问题