get the last day of a month in a year

 function daysInMonth(month,year)
    {
        month =month +1;
        var lastDate=0;
        var m = [31,28,31,30,31,30,31,31,30,31,30,31];
      if((month)!=2)
     {
           lastDate=m[month-1];
      }
    else if(year%4 != 0)
    {
         lastDate= m[1];
     }
else if(year%100 == 0 && year%400 != 0)
{
    lastDate= m[1];
}
else
lastDate= m[1]+1;

         var date=new Date();
         date.setDate(lastDate);
         var strDate=date.toUTCString();
          var day=strDate.substring(0,3);
         }