Find available time spans for specified date

I have a booking event schema with fields start_date and end_date.
I need to find available time slots for the specified date grouped by 30 minutes like in the screenshot.
So if we have the booked events with {start_date: "2022-11-18 18:00", end_date: "2022-11-18 19:00"} and {start_date: "2022-11-18 09:00", end_date: "2022-11-18 9:45"}
9:00, 9:30, 6:00 and 6:30 slots should not be available

Any ideas, guys?

See a related thread.

Your date and time should use real date and time. With strings like you have you might need to implement all the nice date library like $dateToParts, $dateAdd. $dateDiff. And string are slower to compare, take more space to store and more bandwidth to transmit.

Those fields are Date type

The following examples are not Date type

I know. This is just for example, the real values are Dates

So, the only solution is to keep booked and not booked time slots all together

Probably not

but it is the one I use because it is the simplest I could find. May be someone else can enlighten us with something else.

Please share if you come out with something different.