Creating date with numbers (new Date(2012, 03, …) gives wrong month (+1)

Programmers start counting from 0. So months are represented by 0(Jan)-11(Dec).

The reason days don’t follow this rule is to not confuse authors with 30/31 month differences.

From MDN:

month

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

Leave a Comment