Several questions were asked on similar topics, but I canโt find a solution to this particular problem and would be grateful for your input.
I am working on a reservation mechanism where users can book certain services online. I am stuck in searching and displaying available time intervals for a specific day (or week). I know the length of the required time interval (for example, 1 hour) and the working hours in which you can reserve time intervals (for example, from 09:00 to 18:00). In addition, I have a MySQL table that stores existing meetings. The columns related to my questions are as follows:
id start (datetime) end (datetime) 1 '2012-11-16 13:00:00' '2012-11-16 14:30:00' 2 '2012-11-16 15:00:00' '2012-11-16 16:00:00' 3 '2012-11-17 12:00:00' '2012-11-16 15:45:00' 4 '2012-11-17 13:00:00' '2012-11-16 16:15:00' ...
Now, given the information above, I cannot find a good solution (in MySQL or PHP) to get a list of the available time intervals. There is one more condition: time intervals can begin only quarterly. I.e. for the example above, on the 16th available one-hour time slots will be:
09:00, 09:15, 09:30, 09:45, 10:00, ..., 12:00, 16:00, 16:15, ..., 17:00.
Please note that even if the overlap time can be overlapped (as in the sample data), the available time interval cannot overlap.
What do you think is the best way to approach this?
j2dab source share