I am trying to get the result that which time is greater. I mean there is no date only time.
$open_time = date("g:i A", strtotime($restaurant['open_time']));
$close_time = date("g:i A", strtotime($restaurant['close_time']));
$curren_time = date("h:i");
$restaurant['open_time']
and $restaurant['close_time']
is the result from database. It is coming in 24 hour format like 22:30, 10:20.
What i want exactly.
if(($current_time > $open_time) && ($current_time < $close_time)
{
echo "Opened";
}
else
{
echo "Closed";
}
If current_time
is 2:00 AM
and open_time
is 11:00 AM
then the result should echo Closed. And like this if current_time
is 1:00 PM
and closed_time is 11:00 PM
then the result should echo Opened. Hope i explained well. Please ask if you have any doubt in my question.
You can solve thus using 24 hour format time also. But remember you can add date but virtually not from database. You can use to get the greater time