[英]php check current date in time&date range
I need to check the current date in date and time range.我需要在日期和时间范围内检查当前日期。
if(date('N') >= 5 OR date('N') <= 6 AND date('H:i:s') >= "18:00:00" AND date("H:i:s") <= "08:00:00")
{
$orderAvailable = 1;
}
else
{
$orderAvailable = 0;
}
I need to disable order from Thursday 18:00 until Saturday 12:00.我需要从星期四 18:00 到星期六 12:00 禁用订单。 What is the problem with this code?
这段代码有什么问题?
In other words: you want to deactivate orders on换句话说:您想在
That as a condition:那作为一个条件:
if(
(date('N') == 4 AND date('Hi') >= 1800)
OR (date('N') == 5)
OR (date('N') == 6 AND date('Hi') < 1200)
) {
$orderAvailable = 0;
}
else {
$orderAvailable = 1;
}
That was the understandable solution.这是可以理解的解决方案。 The short version:
简短版本:
$orderAvailable = !(date('NHi') >= 41800 AND date('NHi') < 61200);
//true or false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.