var nowdays = new Date(); var year = nowdays.getFullYear(); var month = nowdays.getMonth(); if(month==0){ month = 12; year = year-1; } if(month<10){ month = '0'+month; } var myDate = new Date(year,month,0); var startDate = year+'-'+month+'-01 00:00:0
javascript根据当前日期获取上个月日期 function lastMonthDate(){ var Nowdate = new Date(); var vYear = Nowdate.getFullYear(); var vMon = Nowdate.getMonth() + 1; var vDay = Nowdate.getDate(); //每个月的最后一天日期(为了使用月份便于查找,数组第一位设为0) var daysInMonth = new Array(0,31,28,31,3