I had this working fine for the middle of the year but now that we've rolled over to a new year, my code breaks. I need to get the month name and year for the previous 6 months.
My modified code:
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth();
var i = 0;
do {
$("#pickWinners_month").append($("<option />").val((month > 8 ? "" : "0") + month + "/01/" + year).html(monthNames[month - 1] + " " + year));
if (month == 0) {
month = 11;
year--;
} else {
month--;
}
i++;
} while (i < 6);
Can someone give me a hand with this?