CodeIgniter Forums
Compare Time - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Compare Time (/showthread.php?tid=15955)



Compare Time - El Forum - 02-20-2009

[eluser]sapid_guy[/eluser]
Here is the thing,

I have a table which has
Start Time (00:00:00)
End Time (00:00:00)

So i tried to compare these times to know is it time to start


Code:
$cur_ti = date("H:i:s");
$cur_time = strtotime($cur_ti);

$str_time = $row->start_time;
$end_time = $row->end_time;;
$start_time = strtotime($str_time);
$ends_time = strtotime($end_time);

if ($start_time <= $cur_time && $ends_time >= $cur_time) {

}

Is this logic correct??


Compare Time - El Forum - 02-20-2009

[eluser]sapid_guy[/eluser]
Solved


The logic is correct with bit of modification.

if ($start_time < $cur_time && $ends_time > $cur_time) {

}