//判断日期
//data1 开始时间 data2 结束时间 data要获取的时间
function dataJudge(data1,data2,data){
var start_time = data1;
var end_time = data2;
var bd = new Date(start_time),be = new Date(end_time);
//解决时差问题
var bd_localOffset = bd.getTimezoneOffset() * 60000;
var be_localOffset = be.getTimezoneOffset() * 60000;
//得到本地时间
var bd_time = bd.getTime()+bd_localOffset, be_time = be.getTime()+be_localOffset,time_diff = be_time - bd_time;
var d_arr = [];
for(var i=0; i<= time_diff; i+=86400000){
var ds = new Date(bd_time+i);
var mouth=ds.getMonth()+1<10? ('/'+0)+(ds.getMonth()+1):'/'+(ds.getMonth()+1);
var day=ds.getDate()<10? ('/'+0)+ds.getDate():'/'+ds.getDate();
d_arr.push(ds.getFullYear()+mouth+day)
}
for(var i=0;i<d_arr.length;i++){
if(d_arr[i]===data){
return true
}
}
return false
}
网友评论