user3743266 user3743266 - 1 year ago 39
Javascript Question

Momentjs locale-specific weekdays()

In moment there is a function

that returns an array from sunday - saturday

If I change my locale to EU where first day of the week is monday, for example finland(

the result of
is still starting with (translated) sunday

also: this doesn't change moment.weekdays() result but changes moment.weekday(1) to monday

moment.updateLocale('fi', {
week: {
dow : 1 // Monday is the first day of the week

Is there a way to get weekdays for current locale in the right order(starting with monday) or is modifying the
array myself the only way?

Answer Source

As of 2.13.0 you can pass a bool as the first parameter of the weekday functions. If true, the weekdays will be returned in locale specific order. For instance, in the Arabic locale, Saturday is the first day of the week

For your example in French, this would look like:



["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"]

link to documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download