jeudi 30 juin 2016

Array of months AS3 DATE()

I'm working on a stats page which shows a rolling 12 months of figures. I've created an array to hold the months and a for loop to populate the array starting with the current month as first element in the array

var myDate:Date = new Date();
for(var mn:uint=0; mn<12;mn++){
    myDate.setMonth(myDate.getMonth()+1);
    trace("statMonth +: "+ myDate.month);
    }

The trace produces this:

staMonth: 6 staMonth: 7 staMonth: 8 staMonth: 9 staMonth: 10 staMonth: 11 staMonth: 0 staMonth: 2 staMonth: 3 staMonth: 4 staMonth: 5 staMonth: 6 staMonth: 7

I had to do a double take.. Where is month 1? Is it me? Am I being totally stupid?

Aucun commentaire:

Enregistrer un commentaire