js 获取上个月月底日期

/**
 * 获取上个月月底日期
 */
function getLastMonthAndDay(){
    var nowDate = new Date();
    var year = nowDate.getFullYear();
    var month = nowDate.getMonth();
    if(month == 0){
        month = 12;
        year = year - 1;
    }
    var lastDay = new Date(year,month,0);
    var yyyyMMdd = year+"-"+month+"-"+lastDay.getDate();
    console.log(yyyyMMdd);
}
原文地址:https://www.cnblogs.com/wcnwcn/p/10973687.html