获取上一个月的开始日期和结束日期
?
?获取最后一天 的下一个月第一天 减去 ?一天的毫秒数 就可以得到。
js 中?getMonth() ?比实际月份数要小1.
?
//获取上一月的第一天
?//alert("month:"+now.getFullYear()+","+ now.getMonth());
?
?//var curTime = new Date(2013,(4-1),1);
?var curYear =?curTime?.getFullYear();
?var curMonth =?curTime?.getMonth();
?alert("cur:"+curTime.getFullYear()+"-"+(curTime.getMonth()+1)+"-"+curTime.getDate());?
??
?var curMonthFirstDay = new Date(curYear,curMonth,1);
?var beforeMonth = curMonth-1;
?if(beforeMonth==-1){
? ?curYear = curYear-1;
?beforeMonth = 11;
?}
?
?var beforeStartDate = new Date(curYear,beforeMonth,1);
?alert(beforeStartDate.getFullYear()+"-"+(beforeStartDate.getMonth()+1)+"-"+beforeStartDate.getDate());?
?
?var beforeMonthLastDay = new Date(curMonthFirstDay.getTime() - (24*3600*1000));
?alert(beforeMonthLastDay.getFullYear()+"-"+(beforeMonthLastDay.getMonth()+1)+"-"+beforeMonthLastDay.getDate());