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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM