Skip to content
Advertisement

Substract Time Logic – PHP

I want to show time slots between 2 times. Start time & End time. Used below code, it’s working fine. It loops start and end time and add 30 mins to time. Starts from 2:00pm, 2:30pm, 3:00pm all the way till 10:00pm

JavaScript

What I am stuck on is 2 parts

  • Hide past time, lets say right now is 4:00pm, it should hide past time slots i-e 2:00pm,2:30pm,:3:00pm,3:30pm
  • If right now is 4:00pm, it should start from 5:00pm all the way till 10:00pm. Adding extra buffer time of 1 hour.

Advertisement

Answer

You could insert the current timestamp in your logic like this:

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