Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

momentjs

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

week : {
    dow : 1
}

and moment.weekdays() returns days as in 'en' starting with Sunday. Why is this happening?

like image 653
Adrian Avatar asked Oct 15 '25 07:10

Adrian


1 Answers

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>
like image 179
VincenzoC Avatar answered Oct 19 '25 12:10

VincenzoC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!