Reputation: 4553
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?
Upvotes: 1
Views: 374
Reputation: 455302
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
}
Upvotes: 2