if statements and time php
<p>The user enters a time to hire a bus and the length of hours. I then query this information from mysql database. I find the end time of the hire and figure out how many hours after midnight the hire is for, if any. I'm pretty sure I had this working but now it just isn't working and I cannot see why it won't. Finding the end time is right but my if statement doesn't seem to work. For example, when the end time is "02:00:00" so 2am, it follows the path of the if statement so that the time after midnight is 3 hours, when it should be 2 hours. Any help as to why? Thanks.
($hireid = latest hireid in database)</p>

<pre><code>//GET LATEST TIME AND LENGTH OF HIRE

$result = mysql_query("SELECT time, length FROM hire WHERE hireid='$hireid'") or   die ('Error: '.mysql_error ());

while ($row = mysql_fetch_assoc($result)){

$time = $row['time'];
$length = $row['length'];

}
//FIND AMOUNT OF HOURS BEFORE AND AFTER MIDNIGHT  

echo "Time: " . $time . "&lt;/br&gt;";
echo "Length: " . $length . "&lt;/br&gt;";
echo "Hours: " . $hours . "&lt;/br&gt;";

echo "End time: " . $endtime = date('H:i:s', strtotime($time . '+ ' . $length .  'hours')) . "&lt;/br&gt;";

$hoursafter = 0;

if ($endtime = "01:00:00") {
$hoursafter = 1;
}

if ($endtime = "02:00:00") {
$hoursafter = 2;
}

if ($endtime = "03:00:00") {
$hoursafter = 3;
}


echo "Hours after midnight: " . $hoursafter . "&lt;/br&gt;";
</code></pre>
