js获取本月开始时间和结束时间

来源:互联网 发布:手机dj软件 编辑:程序博客网 时间:2024/05/23 19:23
var firstDate = new Date();        var startDate = firstDate.getFullYear()+"-"+((firstDate.getMonth()+1)<10?"0":"")+(firstDate.getMonth()+1)+"-"+"01";        //alert(firstDate.getFullYear()+"-"+((firstDate.getMonth()+1)<10?"0":"")+(firstDate.getMonth()+1)+"-"+"01");        var date=new Date();        var currentMonth=date.getMonth();        var nextMonth=++currentMonth;        var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1);        var oneDay=1000*60*60*24;        var lastDate =  new Date(nextMonthFirstDay-oneDay);        var  endDate = lastDate.getFullYear()+"-"+((lastDate.getMonth()+1)<10?"0":"")+(lastDate.getMonth()+1)+"-"+(lastDate.getDate()<10?"0":"")+lastDate.getDate();        //alert(lastDate.getFullYear()+"-"+((lastDate.getMonth()+1)<10?"0":"")+(lastDate.getMonth()+1)+"-"+(lastDate.getDate()<10?"0":"")+lastDate.getDate());
}

阅读全文
0 0