I have the following:
$isOlderThenThreeMinutes = $this->getDateModified() <= strtotime('-3 minutes');
pretty basic. How ever I was logging this the whole time and I get 1
every time this check returns. So I thought ok what happens if I wait 15 minutes and check it again, still 1
thus its never truly older then three minutes.
Whats wrong with this? getDateModified()
returns YYYY-MM-DD HH:MM:SS
How do I say: if older then 3 minutes return true, else return false? it returns one every time, even if its 2 seconds old or 30 minutes old ....
You need to convert $this->getDateModified()
to a Unix Timestamp since that is what strtotime(-3 minutes)
returns.
isOlderThenThreeMinutes = strtotime($this->getDateModified()) <= strtotime('-3 minutes');
strtotime()
returns a timestamp, so you would need:
$isOlderThenThreeMinutes = strtotime($this->getDateModified()) <= strtotime('-3 minutes');