js to determine how many days in a certain month in a certain year

function getCountDays(ym) {
var curDate = new Date(ym);
/* Get the current month*/
var curMonth = curDate.getMonth();
/* Generate the actual month: Since curMonth will be 1 less than the actual month, it needs to be added 1 */
curDate.setMonth(curMonth + 1);
/* set the date to 0 */
curDate.setDate(0);
/* return the number of days in the month */
return curDate.getDate();
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325171444&siteId=291194637