判断当前时间是否在某一时间段
作者:互联网
//判断当前时间是否在考核时间内
checkTime(stime,etime){
//开始时间
let arrs = stime.split('-');
let starTime = new Date(arrs[0],arrs[1],arrs[2]);
let startTimes = starTime.getTime();
//结束时间
let arre = etime.split("-");
let endTime = new Date(arre[0], arre[1], arre[2]);
let endTimes = endTime.getTime();
//当前时间
let thisDate = new Date();
let thisDates = thisDate.getFullYear() + "-0" + (thisDate.getMonth() + 1) + "-" + thisDate.getDate();
let arrn = thisDates.split("-");
let nowTime = new Date(arrn[0], arrn[1], arrn[2]);
let nowTimes = nowTime.getTime();
if (nowTimes < startTimes || nowTimes > endTimes) {
return false;
}
return true;
}
标签:某一时间,判断,arrn,arre,let,当前,new,Date,arrs 来源: https://blog.csdn.net/qq_24906761/article/details/89509938