Months represented in JavaScript Date objects are 0-based. That is, January is represented as 0
, February as 1
, March as 2
, etc.
For some interesting answers as to why this behaviour is implemented across many languages, see Zero-based month numbering.
"the combination of zero-based arrays and 1-based month values does bring a problem. To get the month name of month 9, you would have to get item 8 from the month array. Some developers would be happy with decreasing the month number before getting it's name. Others preferred to change the month into something zero-based since people just want to know the name, not the number. It's a personal view."