-2

I am wondering why the date of the constructor and the printed date is different. It is shown as a month late.

Chris Yeung
  • 2,433
  • 4
  • 30
  • 55
  • 1
    possible duplicate of [javascript is creating date wrong month](http://stackoverflow.com/questions/12254333/javascript-is-creating-date-wrong-month) and http://stackoverflow.com/q/25288781/1612146 and http://stackoverflow.com/q/19244052/1612146 and http://stackoverflow.com/questions/10649036/creating-date-with-numbers-new-date2012-03-gives-wrong-month-1 -- The list goes on. – George Jul 21 '15 at 15:33
  • 1
    Because `Integer value representing the month, beginning with 0 for January to 11 for December.` https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date – Tushar Jul 21 '15 at 15:34

2 Answers2

8

Month is zero-based in many languages. This means

0 -> January
1 -> February
2 -> March
...

month
Integer value representing the month, beginning with 0 for January to 11 for December.

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

Wiseguy
  • 19,843
  • 8
  • 62
  • 79
AmmarCSE
  • 29,061
  • 5
  • 39
  • 52
3

See reference: Date object

month
Integer value representing the month, beginning with 0 for January to 11    for December.
initall
  • 2,375
  • 19
  • 27