Why does this declaration result in a momentJS object with Date 1th February 2014 ???

var startDate = moment(new Date(2014, 1, 1));
有帮助吗?

解决方案

Because the second argument is 0-11 in the Date object. (1 being Feb). Its not a MomentJS issue.

Change to new Date(2014, 0, 1)

其他提示

because the month is 0 based. you would do

var startDate = moment(new Date(2014, 0, 1));

for jan.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top