我在这里找到了这个片段。
$resttimefrom = 50000; // 5am
$resttimeto = 170000; // 5pm
$currentTime = (int) date('Gis'); // time now
if ($currentTime > $resttimefrom && $currentTime < $resttimeto)
{
// its before 5pm lets do something
}
else
{
// after 5pm sorry
}
这完全没问题,但我想按照日期限制我正在处理的网站我希望它检查时间戳,如果交货=明天那么他们必须在前一天下午5点之前取消订单。
答案 0 :(得分:2)
$timestamp = time();
$date = date("Y-m-d", $timestamp);
$time = date("G", $timestamp);
$tomorrow = date('Y-m-d', strtotime('tomorrow'));
if ($date == $tomorrow && $time > 5 && $time < 17) {
// It is in-between 5am and 5pm tomorrow.
}
答案 1 :(得分:0)
if (time() >= strtotime(date('Y-m-d', time()).' 5:00:00') && time() <= strtotime(date('Y-m-d', time()).' 17:00:00')) {
// today between 5AM and 5PM
}
else {
}