我有以下内容:
$isOlderThenThreeMinutes = $this->getDateModified() <= strtotime('-3 minutes');
很基本。我一直在记录这个,每次支票回来我都得到1
。所以我想如果我等15分钟再检查会发生什么,仍然是1
,所以它从来没有真正超过3分钟。
这有什么问题?getDateModified()
返回YYYY-MM-DD HH:MM:SS
我怎么说:如果年龄大于3分钟返回true,否则返回false?它每次都返回一个,即使它是2秒前的或30分钟前的....
您需要将$this->getDateModified()
转换为Unix时间戳,因为这是strtotime(-3 minutes)
返回的。
isOlderThenThreeMinutes = strtotime($this->getDateModified()) <= strtotime('-3 minutes');
strtotime()
返回时间戳,因此您需要:
$isOlderThenThreeMinutes = strtotime($this->getDateModified()) <= strtotime('-3 minutes');