function getDaysInMonth(year, month) { var dayNum = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if (new Date(year, 1, 29).getDate() == 29) { dayNum[1] = 29; } return dayNum[month - 1]; }