0

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

var startDate = moment(new Date(2014, 1, 1));
Pascal
  • 11,273
  • 23
  • 91
  • 185
  • 1
    Has nothing to do with `momentjs`. [MDN Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) *"**month:** Integer value representing the month, beginning with 0 for January to 11 for December."* – cookie monster Mar 26 '14 at 20:07

2 Answers2

4

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)

Matt Lo
  • 4,963
  • 1
  • 19
  • 21
0

because the month is 0 based. you would do

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

for jan.

Chris Brickhouse
  • 650
  • 5
  • 15