Month off by one

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

kpt

Month off by one

Post by kpt »

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());

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Month off by one

Post by Mike Hale »

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()]);