Moment.js first day of the week incorrect

momentjs

Solution

For anyone who come across this question lately, moment now support `lang` method to set locale specific setting.

Setting first week to be Monday:

moment.lang('zh-cn', {
    week : {
        dow : 1 // Monday is the first day of the week
    }
});

var date = moment().weekday(0); // date now is the first day of the week, (i.e., Monday)

Problem

I'm working with Moment.js for my first time. I tried to retrieve the date of the first day of the week, and in Europe this is normally Monday. Whatever I do, I get Sunday as result of the first day of the week. I tried to set-up different languages (local or globally), but to no avail. I use the langs.min.js file from the moment.js github page. The language file of "en-gb" and "fr" has the line of code: ``` dow : 1, // Monday is the first day of the week. ``` So I would get the date of monday when I ask for the first day of the week right? I keep getting Sunday as output. ``` // Create moment object var localLang = moment(); // Set language to french localLang.lang('fr'); // Test language localLang.lang(); // Output: fr // Retrieve first day of the week and format it var dow = localLang.startOf('week').format('dddd DD-MM-YYYY'); // Output: dimanche 14-04-2013 ``` Dimanche is french for Sunday.. As you see, moment.js can use the language file succesfully but doesn't use the day of the week configuration JSfiddle with moment.js and langs.js to test: JSFiddle edit: I can get the date of Monday instead of Sunday with `day(1)` instead of `startOf('week')`. But using `day(0)`I still get Sunday as a result. Why isn't monday the first day of the week, as configured in the language files.

Original source