麻烦计算Php5的时差

I am creating a Php application of exam where i want to stop exam in 1 hour

I send test start time and end time in database code of inserting time in db

<?php  $date = date('h-i-sa');
      $date1 = date('h-i-sa',strtotime('+5 min'));
      $sql = "insert into timer(name,start_time,end_time) values('$name','$date','$date1')"; ?>

now i fatch this time by fatch query

<?php $sel = "select * from timer where id=28"; 
$ex1=$conn->query($sel);
$r=$ex1->fetch_object(); ?>

Now I got exam start time = <?php $s_time = echo $r->start_time; ?>

Exam end time = <?php $e_time = echo $r->end_time; ?>
and
Latest Time = <?php date_default_timezone_set("Asia/Kolkata"); $l_time = echo date('h-i-sa'); ?> Now i need difference between End time & Latest time means $l_time & $e_time

i wrote following code , but its not working

<?php
    if($l_time == $e_time)
    {
         echo 'time over';
         echo "<script>alert('time over'); </script>";
         return 'index.php';
    }
?>

image output

Learn Yii Framework here

if($l_time <= $e_time)
{
      alert('time);
}

The if statement is wrong. Moving time is never (or very rarely) equal while running a script. Your if statement should be one of the following. I can't tell which one is correct because your variable naming scheme is hard to read.

if($l_time >= $e_time)

// or

if($l_time <= $e_time)