js判断某年某月有多少天

function getCountDays(ym) {
var curDate = new Date(ym);
/* 获取当前月份 */
var curMonth = curDate.getMonth();
/* 生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 */
curDate.setMonth(curMonth + 1);
/* 将日期设置为0 */
curDate.setDate(0);
/* 返回当月的天数 */
return curDate.getDate();
}

猜你喜欢

转载自www.cnblogs.com/wangyunhui/p/8981720.html