Saturday, June 1, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  76] [ 6]  / answers: 1 / hits: 22973  / 8 Years ago, fri, january 13, 2017, 12:00:00

Well, I want to check if a day of date is Monday like:


var myDate = new Date();
moment(myDate, 'DD-MM-YYYY').dayIs('monday')

In my country the first day of week is Monday, so, really I want check if the input date is begin of week.


I try using moment(myDate, 'DD-MM-YYYY').startOf('isoweek') but, this don't work for me.


More From » momentjs

 Answers
70

According to the documentation - Moment.js has a locale setting which should solve this for you;



Day of Week (Locale Aware) 2.1.0+


moment().weekday(Number);


moment().weekday(); // Number


Gets or sets the day of the week according to the locale.


If the locale assigns Monday as the first day of the week, moment().weekday(0) will be Monday. If Sunday is the first day of the week, moment().weekday(0) will be Sunday.



Here you can see how to set the locale;


moment.locale('en'); // set to english


[#59361] Wednesday, January 11, 2017, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jarod

Total Points: 62
Total Questions: 111
Total Answers: 83

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
jarod questions
;