@mrhooMar 07.2007 — #You need the year as well, to get all the Febs correctly.
[CODE]Date.prototype.monthDays= function(){ var m= this.getMonth()+1; switch(m){ case 4: case 6: case 9: case 11: return 30; case 2: var y= this.getFullYear(); if (y > 1582){ if(y%400 ==0 || (y%100 !=0 && y%4==0)) return 29; return 28; } else return ((y % 4 == 0) ? 29 : 28 ); default: return 31; } }[/CODE]// call it on any Date object:
new Date(2008,0).monthDays()// remember, months start at 0 for January
@felgallMar 07.2007 — #pass the year and month you want the number of days for into the following function if you want something shorter than the above solution:
<i> </i>function daysInMonth(year,month) { var t = new Date(year, month - 1, 32); return 32 - t.getDate(); }