如何检查是否在过去30天内

时间:2012-10-08 23:44:34

标签: php

我正在尝试做这样的事情:

如果“关闭日期”在过去30天内,请执行此操作。如果没有,请执行此操作。

我将如何在php中编写?

1 个答案:

答案 0 :(得分:1)

假设你有“关闭日期”作为unix时间戳我会尝试类似:

$month = 60 * 60 * 24 * 30; // month in seconds
if (time() - $closingTime < $month) {
  // within the last 30 days ...
} else {
  // the closing date it longer ago ...
}