PHP检查MySQL数据库DateTime

I'm working on a project which allows users to assign a booking to a taxi, but the value should only show up if the time requested is expected to be in at least 2 hours time.

here is the storage php / sql.

<?php

$query = "INSERT INTO Taxi(fname, lname, number, unit, snumber, sname, suburb, dsuburb, dt, status) VALUES('{$fname}','{$lname}','{$contact}','{$unit}','{$snumber}','{$sname}','{$suburb}','{$dsuburb}','{$dt}','{$status}')";
if (mysqli_query($conn, $query)) {


    $date = date_create($dt);
    $dateFormatted = date_format($date, 'g:ia \o
 d/m/y');
    echo "Thank you! Your booking reference number is " . mysqli_insert_id($conn) . " you will be picked up in front of your provided address at " . date_format($date, 'g:ia \o
 l jS F Y') . ".";

} else if (!mysqli_query($conn, $query)) {
    echo mysqli_error($conn);
}
mysqli_close($conn);


?>

Here is the PHP used to assign the taxi, now to show in table it should only show values in the unassigned table when the time is going to be 2 hours or more into the future. How can I do time comparisons?

<?php

                require_once ("settings.php");
                $conn = @mysqli_connect($host, $user, $pswd)
                or die('Failed to connect to server');

                @mysqli_select_db($conn, $dbnm)
                or die('Database not available');

                $query = "SELECT id, fname, lname, number, unit, snumber, sname, suburb, dsuburb, dt, status FROM taxi WHERE status = 'unassigned'";

                $results = mysqli_query($conn, $query);

                echo "<table width='100%' border ='1'>";
                echo "<tr><th>Booking Id</th><th>First<br>Name</th><th>Last<br>Name</th><th>Contact</th><th>Unit<br>Number</th><th>Street<br>Number</th><th>Street<br>Name</th><th>Suburb</th><th>Destination<br>Suburb</th><th>Date/Time</th><th>Status</th></tr>";

                while($row = mysqli_fetch_assoc($results)) {
                    echo "<tr>";
                    echo "<td> {$row['id']}</td>";
                    echo "<td> {$row['fname']}</td>";
                    echo "<td> {$row['lname']}</td>";
                    echo "<td> {$row['number']}</td>";
                    echo "<td> {$row['unit']}</td>";
                    echo "<td> {$row['sname']}</td>";
                    echo "<td> {$row['snumber']}</td>";
                    echo "<td> {$row['suburb']}</td>";
                    echo "<td> {$row['dsuburb']}</td>";
                    echo "<td> {$row['dt']}</td>";
                    echo "<td> {$row['status']}</td>";
                    echo "</tr>";
                }

                $query = "SELECT id, fname, lname, number, unit, snumber, sname, suburb, dsuburb, dt, status FROM taxi WHERE status = 'assigned'";

                $results = mysqli_query($conn, $query);

                echo "<table width='100%' border ='1'>";
                echo "<tr><th>Booking Id</th><th>First<br>Name</th><th>Last<br>Name</th><th>Contact</th><th>Unit<br>Number</th><th>Street<br>Number</th><th>Street<br>Name</th><th>Suburb</th><th>Destination<br>Suburb</th><th>Date/Time</th><th>Status</th></tr>";

                while($row = mysqli_fetch_assoc($results)) {
                    echo "<tr>";
                    echo "<td> {$row['id']}</td>";
                    echo "<td> {$row['fname']}</td>";
                    echo "<td> {$row['lname']}</td>";
                    echo "<td> {$row['number']}</td>";
                    echo "<td> {$row['unit']}</td>";
                    echo "<td> {$row['sname']}</td>";
                    echo "<td> {$row['snumber']}</td>";
                    echo "<td> {$row['suburb']}</td>";
                    echo "<td> {$row['dsuburb']}</td>";
                    echo "<td> {$row['dt']}</td>";
                    echo "<td> {$row['status']}</td>";
                    echo "</tr>";
                }
                echo "<br>";
                mysqli_free_result($results);
                mysqli_close($conn);
            ?>

something like ...

$requestedDateTime = $_POST["datetime"];
$interval = 2;
$endDateTime = date("$requestedDateTime", strtotime("+{$interval} hours"));

 if($endDateTime >= $requestedDateTime) {
   //your code here to accept the booking
 }
 else {
    //error msg time is too short 
 }