-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,613
  • 6
  • 34
  • 57
  • 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
  • 20,522
  • 8
  • 65
  • 81
AmmarCSE
  • 30,079
  • 5
  • 45
  • 53
3

See reference: Date object

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