Why moment.weekdays() returns days starting with Sunday when I specified that first day is Monday?

后端 未结 1 1997
攒了一身酷
攒了一身酷 2021-01-22 19:18

I set the locale to \'ro\' and now weekdays are in romanian. But, I also set the

week : {
    dow : 1
}


        
相关标签:
1条回答
  • 2021-01-22 20:02

    You have to use moment.weekdays(true);

    As the docs states:

    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

    Here a live example:

    moment.locale('ro');
    // duminică to sâmbătă
    console.log(moment.weekdays());
    // locale aware: luni to duminică
    console.log(moment.weekdays(true));
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>

    0 讨论(0)
提交回复
热议问题