PHP/MySQL - Find available time slots
<p>I have found a few questions on similar topic, but I can't find a solution to this specific problem.</p>

<p>I'm currently working on a booking system, where it should be possible for users to book services online. I'm stuck at finding a way to display the available timeslots within a specific day.</p>

<p>The information that I know is the length of the nedded time slot (eg. 30 minutes) and the business hours where it's possible to book a time.</p>

<p>I already have a MySQL table which stores already existing appointments.</p>

<pre><code>id  start (datetime)        end (datetime)
1   '2016-04-09 12:00:00'   '2016-04-09 13:30:00'
2   '2016-04-09 15:00:00'   '2016-04-09 17:00:00'
3   '2016-04-09 12:00:00'   '2016-04-09 15:45:00'
4   '2016-04-09 13:00:00'   '2016-04-09 16:15:00'
...
</code></pre>

<p>I can't really seems to find a good solution (MySQL or PHP) for retrieving a list of available time slots. The only condition is that time slots can only start in quarterly steps. Ie. for the example data above on the 16th available one hour time slots would be:
09:00, 09:15, 09:30, 09:45, 10:00, ..., 12:00, 16:00, 16:15, ..., 17:00.</p>

<p>Please note that even though there may be overlapping times (as in sample data) an available time slot cannot overlap.</p>

<p>What would you think is the best way to approach this?</p>