Welcome Guest, Not a member yet? Register   Sign In
Compare Time
#1

[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??
#2

[eluser]sapid_guy[/eluser]
Solved


The logic is correct with bit of modification.

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

}




Theme © iAndrew 2016 - Forum software by © MyBB