tags:

views:

20

answers:

1

I am having two times in database.
Starting Time 07:00 and
Ending Time 07:25 and
If your chooses the starting time from my application 07:10 and End time is 07:35 I need to inform the time is not available for booking.
How can I check this 07:10 and 07:35 fall between 07:00 and 07:25 using PHP?Thanks in advance?

Update:
They May Give like this also 06:50 to 07:15.At that time also I need to find this time falls between the previous times?

+1  A: 

You can convert the times into number of minutes since the start of the day which will make the comparison easier.

07:00 = 07 * 60 + 00 = 420 call this $Start 

and

07:25 = 07 * 60 + 25 = 445 call this $End

Similarly convert your user input hh:mm to min as above and call them $userStart and $userEnd. Now all you need to do is:

if($userStart >= $Start && $userEnd <= $End) {
  // valid
}
codaddict
I simply use the strtotime function and use the code like above for condition checking.I got the result.Thanks.
vinothkumar