Possible Duplicate:
javascript is creating date wrong month
In my code, I create Date by this line:
var date = new Date('2012', '01', '20')
and then using:
alert(date);
I get the result:
I don’t really understand why not Jan instead of Feb?
jsFiddle: http://jsfiddle.net/U5m8N/
The “Month” part of
var date = new Date('2012', '01', '20');is zero-indexed.Start counting at
0, and you got your month. (So, January is0, Feb1, etc.)Also, while JavaScript does accept strings as parameters, you should be using integers, as the documentation suggests:
Date Documentation