Er Sahaj Arora Er Sahaj Arora - 1 year ago 77
PHP Question

Trouble Calculating Time Difference in 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";
$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; ?>


Latest Time =
$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

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

image output

Learn Yii Framework here

Answer Source
if($l_time <= $e_time)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download