php - 如果时间和日期早于 php

标签 php date time

我在这里找到了这个片段。

$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/

相关文章:

c# MCRYPT_RIJNDAEL_256 php中的加密解密类

android - 在 Android 中使用 HTML5 日期输入元素

php - 11 月 30 日 -0001 按时间戳返回

java - 这是什么日期格式? 2011-08-12T20 :17:46. 384Z

php - 使用 foreach 引用循环的 var_dump 输出

php - 在多个浏览器上同步用户输入

php - Laravel:创建一个影响数据库中列的按钮

java - 创建 JSpinner 错误的子类

c - 使用 difftime 获取从现在到 future 的时差(以秒为单位)

php - 日期和时间输入