本文章主要介绍了js 判断当前日期时间是否处于某个日期范围,具有不错的的参考价值,希望对您有所帮助,如解说有误或未考虑完全的地方,请您留言指出,谢谢!
export function compareDate(currentTime, sportsTime) {
let curTimeBegin = new Date(currentTime[0]);
let curTimeEnd = new Date(currentTime[1]);
let sprTimeBegin = new Date(sportsTime[0]);
let sprTimeEnd = new Date(sportsTime[1]);
if (curTimeBegin >= sprTimeBegin && curTimeEnd <= sprTimeEnd) {
return true;
}
return false;
}
export function isDuringDate(curDate, beginDateStr, endDateStr) {
(curDate = new Date(curDate)((beginDate = new Date(beginDateStr)))),
(endDate = new Date(endDateStr));
if (curDate >= beginDate && curDate <= endDate) {
return true;
}
return false;
}
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/228261.html