function
checkTime(stime, etime) {
var
arrs = stime.split(
"-"
);
var
startTime =
new
Date(arrs[0], arrs[1], arrs[2]);
var
startTimes = startTime.getTime();
var
arre = etime.split(
"-"
);
var
endTime =
new
Date(arre[0], arre[1], arre[2]);
var
endTimes = endTime.getTime();
var
thisDate =
new
Date();
var
thisDates = thisDate.getFullYear() +
"-0"
+ (thisDate.getMonth() + 1) +
"-"
+ thisDate.getDate();
var
arrn = thisDates.split(
"-"
);
var
nowTime =
new
Date(arrn[0], arrn[1], arrn[2]);
var
nowTimes = nowTime.getTime();
if
(nowTimes < startTimes || nowTimes > endTimes) {
return
false
;
}
return
true
;
}
var
timebool=checkTime(
'2016-8-1'
,
'2016-8-10'
);
if
(timebool==
true
){
document.write(
'当前日期在指定时间段内'
);
}
else
{
document.write(
'当前日期不在指定时间段内'
);
}