In moment there is a function moment.weekdays()
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(moment.locale('fi')
)
the result of moment.weekdays()
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 moment.weekdays()
array myself the only way?
Moment construction falls back to js Date. This is discouraged and will be removed in an upcoming major release. This deprecation warning is thrown when no known format is found for a date passed into the string constructor.
To get the current date and time, just call moment() with no parameters. var now = moment(); This is essentially the same as calling moment(new Date()) . Note: From version 2.14.0, moment([]) and moment({}) also return now.
_i will never be a moment object. _i can also be undefined, in the case of creating the current moment with moment() . _d is the instance of the Date object that backs the moment object. If you are in "local mode", then _d will have the same local date and time as the moment object exhibits with the public API.
You set locale with moment. locale('de') , and you create a new object representing the date of now by moment() (note the parenthesis) and then format('LLL') it. The parenthesis is important.
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:
moment.locale("fr")
moment.weekdays(true)
output:
["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"]
link to documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With