PHP - 如何比较两个不同的日期时间? [重复]

This question already has an answer here:

In the database it is set for current_timestamp I am creating a script to run every hour that will compare the time from the Database then from local server see if it has been more than one hour so far I have this but confused where to go from here:

<?php
require('../config/dbconfig.php');
$sql = "SELECT * FROM stocks";
$result = mysqli_query($dbconfig,$sql);
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)) {
    $time = $row["TimeBought"];
}
$Time = date("Y-m-d H:i:s",$time);
$DateTime = time();
$NewTime = strtotime($Time);

What should I do from here?

</div>

It is better to use DateTime object instead of date function.

$now = new DateTime();
$date = new DateTime('2014-06-04');

if ($now > $date) {
    echo 'The date is in the past.';
} else {
    echo 'The date is in the future.';
}