Check if the input day is Monday with moment.js

北城以北 提交于 2019-12-05 15:12:36

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!