I'm trying to compare these 2 DateTimes. I'm storing one in a database that is stored whenever a new row is inserted. The other one is the current DateTime, but I'm trying to add two minutes to it and then compare it.
My current code:
$time = $cached_data["last_update"];
$date = new DateTime ('now');
$datef = $date->format('Y-m-d H:i:s');
// Check if the cached data has expired and if it has then update the data
if($datef > ($time)) {
echo "updated";
}
Echoing both the $datef and the $time gives:
$datef: 2016-04-06 00:23:43
$time: 2016-04-05 18:21:03
and the script echoes out "updated".
I realize the time on my system and the time of my database are different, but how would I add the two minutes to the $datef
and would this work?