简体   繁体   English

JS时刻,实际一周的第一天不正确

[英]Moment JS, first day of actual week is incorrerct

I'm trying to get first day (monday of actual week (today is Sunday, last day of the week)) using: 我正在尝试使用以下方法获取第一天(实际一周的星期一(今天是星期天,一周中的最后一天)):

dateFrom = moment().day(1).format('YYYY-MM-DD');

But it returns: 但它返回:

Start date range is: 2014-11-10 

But it should be 但这应该是

  Start date range is: 2014-11-3

How can i solve it please and what i'm doing wrong? 我该如何解决?我在做什么错?

Thanks for any help. 谢谢你的帮助。

The documentation says that Sunday (0) is the first day of the week. 该文档说星期日(0)是一周的第一天。 So today we are in the week 2014-11-09 to 2014-11-16. 今天是2014-11-09至2014-11-16。 You request the Monday (1) of that week, which is 2014-11-10. 您要求该周的星期一(1),即2014-11-10。

http://momentjs.com/docs/#/get-set/day/ http://momentjs.com/docs/#/get-set/day/

Try this: http://momentjs.com/docs/#/get-set/weekday/ 试试这个: http : //momentjs.com/docs/#/get-set/weekday/

moment().weekday(0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM