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();
}

posted @ 2018-05-02 18:16  neo_o  阅读(3668)  评论(0编辑  收藏  举报

愿你的生活只有诗和远方