문제

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