Skip to content
Advertisement

Check TimeSlot is between another Time Slot

So I have block time and appointment time let’s say block time is

JavaScript

and the appointment time is

JavaScript

now I want to check if the appointment time is between block time and vice versa

my current code

JavaScript

other conditions

condition 1

if appointment time is

JavaScript

and block time is

JavaScript

then also it should not allow booking

condition 2

if block time is

JavaScript

and appointment time is

JavaScript

condition 3

if appointment time is 13:00-14:00 and block time is 14:00-15:00 then appointment booking is allowed

Advertisement

Answer

So 2 times won’t collide if one starts after the other one ends OR one ends before the other one starts.

Snippet:

JavaScript

Online Demo

So your driver code would be like:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement