检查日期是在同一个月的某个日期之前还是之后

时间:2012-05-08 11:09:54

标签: php

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

2 个答案:

答案 0 :(得分:3)

应该这样做......

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

答案 1 :(得分: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