Getting localized day of week

前端 未结 2 1988
无人及你
无人及你 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:51

    I use Date.toLocaleString(), for example:

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

    or

    d.toLocaleString('sk-SK', {weekday: 'short'});
    

提交回复
热议问题