Node.js/日期
来自康健生活
< Node.js
引言
自然年月
取目标月份的下一个月份1号的前1天,即目标月的最后一天。
natureMonth(curDate, step){
let targetDateLastDay = new Date(curDate.getFullYear(), curDate.getMonth() + step + 1, 0);
return new Date(curDate.getFullYear(), curDate.getMonth() + step, Math.min(curDate.getDate(), targetDateLastDay.getDate()));
}
No categories