title: Trouble Calculating Time Difference in Php5
body: <p>I am creating a Php application of exam where i want to stop exam in 1 hour </p>
  
  <p>I send test start time and end time in database
  code of inserting time in db </p>
  
  <pre><code>&lt;?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')"; ?&gt;
  </code></pre>
  
  <p>now i fatch this time by fatch query</p>
  
  <pre><code>&lt;?php $sel = "select * from timer where id=28"; 
  $ex1=$conn-&gt;query($sel);
  $r=$ex1-&gt;fetch_object(); ?&gt;
  </code></pre>
  
  <p>Now I got
   exam start time  = <code>&lt;?php $s_time = echo $r-&gt;start_time; ?&gt;</code> <br><br>
   Exam end time = <code>&lt;?php $e_time = echo $r-&gt;end_time; ?&gt;</code> <br>
  and <br>
  Latest Time = <code>&lt;?php
                     date_default_timezone_set("Asia/Kolkata");
                     $l_time = echo date('h-i-sa');
                 ?&gt;</code>
  Now i need difference between End time &amp; Latest time means  $l_time &amp; $e_time</p>
  
  <p>i wrote following code , but its not working</p>
  
  <pre><code>&lt;?php
      if($l_time == $e_time)
      {
           echo 'time over';
           echo "&lt;script&gt;alert('time over'); &lt;/script&gt;";
           return 'index.php';
      }
  ?&gt;
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/eX1XN.png" rel="nofollow">image output</a></p>
  
  <p><a href="http://www.facebook.com/WebDeveloperSahajArora" rel="nofollow">Learn Yii Framework here</a></p>