php question… how to check if something is between two values?

后端 未结 5 1855
你的背包
你的背包 2021-01-23 08:40

I know I\'m missing something easy here... I\'ve been trying different operators, but haven\'t been able to figure this out...

How do I go about checking to see if the

5条回答
  •  别那么骄傲
    2021-01-23 09:03

    To do a comparison like this you need to do separate comparisons. If $d is the date you want to compare, $d1 is the earlier date, and $d2 is the later date, it would be something like:

    if ((strtotime($d) > strtotime($d1)) and (strtotime($d) < strtotime($d2))) {
        return true;
    } else {
        return false;
    }
    

提交回复
热议问题