Is there a reason why the enumerated value of the current month is off by one? The following displays 7, not 8. (It's currently August.)
Code: Select allvar today = new Date();
alert(today.getMonth());
Month off by one
-
Mike Hale
Month off by one
But getMonth and getDay return a zero based index with 0 being January or Sunday. My guess would be so those indexes can work well with arrays which are also zero based.
Code: Select allvar d=new Date();
var month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
alert("The current month is " + month[d.getMonth()]);
Code: Select allvar d=new Date();
var month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
alert("The current month is " + month[d.getMonth()]);