momentjs - Moment.js first day of the week incorrect -
i'm working moment.js first time. tried retrieve date of first day of week, , in europe monday. whatever do, sunday result of first day of week.
i tried set-up different languages (local or globally), no avail. use langs.min.js file moment.js github page. language file of "en-gb" , "fr" has line of code:
dow : 1, // monday first day of week.
so date of monday when ask first day of week right? keep getting sunday output.
// create moment object var locallang = moment(); // set language french locallang.lang('fr'); // test language locallang.lang(); // output: fr // retrieve first day of week , format var dow = locallang.startof('week').format('dddd dd-mm-yyyy'); // output: dimanche 14-04-2013
dimanche french sunday.. see, moment.js can use language file succesfully doesn't use day of week configuration
jsfiddle moment.js , langs.js test: jsfiddle
edit: can date of monday instead of sunday day(1)
instead of startof('week')
. using day(0)
i still sunday result. why isn't monday first day of week, configured in language files.
for come across question lately, moment support lang
method set locale specific setting.
setting first week monday:
moment.lang('zh-cn', { week : { dow : 1 // monday first day of week } }); var date = moment().weekday(0); // date first day of week, (i.e., monday)
Comments
Post a Comment