I've noticed that in JavaScript, when creating a Date
, months are zero based, and days aren't.
For example:
var foo = new Date(2012, 1, 1)
produces February 1st 2012
Why is this?
date formatjavascript
I've noticed that in JavaScript, when creating a Date
, months are zero based, and days aren't.
For example:
var foo = new Date(2012, 1, 1)
produces February 1st 2012
Why is this?
Best Answer
Most likely the idea is, that the months are thought of as an index into an array of month names, while days are simply "counted".