DateTime current date + 2 mins compared to stored datetime
<p>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.</p>

<p>My current code:</p>

<pre><code>$time = $cached_data["last_update"];
$date = new DateTime ('now');
$datef = $date-&gt;format('Y-m-d H:i:s');

// Check if the cached data has expired and if it has then update the data
if($datef &gt; ($time)) {

    echo "updated";
}
</code></pre>

<p>Echoing both the $datef and the $time gives:</p>

<pre><code>$datef: 2016-04-06 00:23:43

$time: 2016-04-05 18:21:03
</code></pre>

<p>and the script echoes out "updated".</p>

<p>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 <code>$datef</code>and would this work?</p>