我在这里找到了这个片段。
$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 点之前取消订单。
最佳答案
$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.
}
关于php - 如果时间和日期早于 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10512675/