提问人:Luuc 提问时间:8/1/2023 更新时间:8/1/2023 访问量:25
PHP:如何检查一个日期时间值是否位于其他两个日期时间值之外
PHP: How to check if one datetime value lies outside of two other datetime values
问:
我正在开发一个可以显示错误通知的网站。当当前日期存在于数据库中设置的开始时间和结束时间之间时,将激活这些通知。检查当前日期是否存在于这两个值之间,是在我的代码中的某些地方完成的,使用:
if($Notification['beginTime'] < $currentDate && $Notification['endTime'] > $currentDate){
error_log("something went wrong");
} else{
updateInternalNotification();
}
但是,我现在想切换 if 语句,以便它检查当前日期是否在开始时间和结束时间之外,因此通知未处于活动状态。
我试过这样做:
if($currentDate < $Notification['beginTime' && $currentDate > $Notification['endTime']){
updateInternalNotification();
}
但是,在我看来,一个 dateTime 值不能位于其他两个值之外。这对我来说没有意义。你们谁能帮我了解这种情况?
谢谢。
答: 暂无答案
评论
&&
||
$Notification['beginTime'
$Notification['beginTime']