js获取某个日期的起始周日期及两个日期的间隔天数

//获取起始周
var time=$("#exportWeek").val();
var time_=new Date(Date.parse(time.replace(/-/g,"-")));
var now = new Date(time_);
var nowTime = now.getTime() ;
var day = now.getDay();
var oneDayLong = 24*60*60*1000 ;
var MondayTime = nowTime - (day)*oneDayLong  ;
var SundayTime =  nowTime + (6-day)*oneDayLong ;
var monday = new Date(MondayTime);
var sunday = new Date(SundayTime);

//获取间隔天数
function getDaysBetween(dateString1,dateString2){
    var  startDate = Date.parse(dateString1);
    var endDate = Date.parse(dateString2);
    var days = (endDate - startDate) / (1*24*60*60*1000);
    return parseInt(days);
}

 

你可能感兴趣的:(JavaScript)