js 获取当前月份 第一天和最后一天

js 获取当前月份 第一天和最后一天
var now = new Date(); //当前日期 
    var nowMonth = now.getMonth(); //当前月 
    var nowYear = now.getFullYear(); //当前年 
    //本月的开始时间
    var monthStartDate = new Date(nowYear, nowMonth, 1); 
    //本月的结束时间
    var monthEndDate = new Date(nowYear, nowMonth+1, 0);
    var timeStar=Date.parse(monthStartDate)/1000;//s
    var timeEnd=Date.parse(monthEndDate)/1000;//s

注意:js是精确毫秒的,php是精确到秒的

原文地址:https://www.cnblogs.com/wentutu/p/11078347.html