【问题标题】:Check if date is before or after a certain date in the same month检查日期是在同一个月的某个日期之前还是之后
【发布时间】:2012-05-08 11:09:54
【问题描述】:

我正在使用 PHP (Codeigniter) 开发一个 Web 应用程序。 当用户在应用程序中请求某个资源时,我需要检查今天的日期是在本月 25 日之前还是之后。我怎样才能做到这一点?我不知道该怎么做。

【问题讨论】:

标签: php


【解决方案1】:

应该这样做...

if ( date('j') < 25 ) {
    // date before 25th
}

【讨论】:

    【解决方案2】:

    您可以将date 函数与j 格式类型一起使用

    if (date('j') > 25) {
        // It is after the 25th
    } elseif (date('j') < 25) {
        // It is before the 25th
    } else {
        // It is the 25th
    }
    

    更多信息请见http://php.net/manual/en/function.date.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多