/** * 获取上个月月底日期 */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);}