var currentDate = new Date();
var currentYear = currentDate.getFullYear();
var currentMonth = currentDate.getMonth();
var currentMonthLastDate = (new Date(currentYear, currentMonth, 0)).getDate();
var daysLeftInMonth = currentMonthLastDate - currentDate.getDate();
console.log(daysLeftInMonth);
您可以使用以下程式碼取得一個月的天數:
本月剩餘天數