检查给定日期是否在工作周内(周一至周五)

Checking to see if a given Date is within a work week (Monday-Friday)

本文关键字:周一 周五 工作周 日期 是否 检查      更新时间:2023-09-26

如何检查给定的日期,我们称之为(dateX)是否在(当前日期)工作周(周一至周五)内

逻辑:

If (dateX is within the present work week of Monday-Friday) {  return true }
Else { return false }

//Date Format is: yyyy-mm-dd
//dateX = 2016-10-11
If (2016-10-11 is within 2016-10-10 to 2016-10-14) { then return true }
Else { return false }

你可以试试这个

if(datebetweenCheck("10/09/2016","10/10/2016","12/09/2016"))
{
    alert("Yes");
}
else
{
    alert("No");
}
function datebetweenCheck(from,to,current) {
    var fromDate,toDate,currentDate;
    fromDate = Date.parse(from);
    toDate = Date.parse(to);
    currentDate = Date.parse(current);
    if((currentDate <= toDate && currentDate >= fromDate)) {
        return true;
    }
    return false;
}