JQ如何获取上个月第一天和最后一天日期?
元素模板为您解答
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:00'; //上个月第一天
var endDate = year+'-'+month+'-'+myDate.getDate()+' 23:59:00';//上个月最后一天