Search code examples
javascriptutc

Why Date.UTC(2015, 08, 31) == Date.UTC(2015, 09, 01) in javascript?


My script broke up after yesterday because both Date.UTC(2015, 08, 31) and Date.UTC(2015, 09, 01) provides same timestamp 1443657600000.

This is the only pair of days which provide same result. what am I missing?


Solution

  • The month parameter is zero-indexed. So 8 is actually september which only has 30 days. So it flows over to october.

    Reference: Date.UTC()