Handling multiple store opening hours per day

This is a bit tricky. So you need to take open time and closing time from the user. Then count the minutes and store them in DB like
Open time count = Open time:Extract hoursX60+Open time:Extract minutes
Closing time count = Closing time:Extra hoursX60+Closing time:Extra minutes

Now you know at exactly what minute the store opens and at exactly what minute the store closes, on a 24 hour clock. While displaying list of “Open stores”, you need to count the minutes of current time of the day like
Current date/time:Extract hoursX60+Current date/time:Extract minutes
Now you need to compare this current time count with open time count and closing time count to check whether a store is open or closed.
To add extra availability from front end of user dashboard, there should be a button to mark them “Currently open” manually and there should be “Yes/no” field in the database. If they click on “Currently open” beyond their timings, you need to change that “Yes/no” field to “Yes”. In the page where you are displaying stores, you can for this “Yes/no” field’s value, if it’s “Yes”, that store should be displayed as open regardless of their timings.
They need to click on “Close store” button manually to close it, which turns “Yes/no” field to “No”.

1 Like