Hi, I have a list of stores that have open/close times for each day of the week. Based off what the store hours are, I’ve created conditional statements for a text that will say ‘Open’ if the user’s current time is within the store’s open to close time. The opposite will happen if the user’s current time is outside of the open to close time.
The conditional statement I’ve set keep saying a store is ‘Closed’ even though the store should be ‘Open’, based on the user’s time.
Here’s what the conditions are for the text (first 3 are open/close conditions that I need help on, last 2 are work as they should):
Try to store the open and close hours as number (in minutes) in your database.
Sumday 08:00 to 20:00 will be Sunday 480 to 1200.
08:00 = 8 x 60 = 480
20:00 = 20 x 60 = 1200
Now, just check the weekday of your user, using Current Date/Time, find this entry in your database and divide the Current Time by 60. If the result is between 480 and 1200, then your store is open!
@rpetribu I get the logic behind this but I can’t seem to figure out ways to execute this in Bubble.
I’m facing three issues: 1. I inputted hours to be 480 to 1260, and when I divided these values by 60, I’m still seeing 480 and 1260 on the front-end side. How do I correctly create the formula to show 8:00am and 9:00pm?
Create a database to store the data of each Store (think you already did it). In this database, I would have 4 fields to control this “time” thing.
Open_hour_text: 08:00
Open_hour_number: 480
Close_hour_text: 20:00
Close_hour_number: 1200
In my Store’s page, in the text filed that displays the opening and closing hours, I would simply get the “Open_hou_text” and “Close_houre_text”. Simple as that…
Now, to dynamically toggle the sign “Open/Close” based in users Current Date/Time you will need extrat the hours and the minutes:
Current Date/Time:Extrat Hours*60 + Current Date/Time:Extrat Minutes
It the time is 14:40, then the result of this operation will be: 880, follow?
If 880 is between Open_hour_number and Close_hour_number , than your store is open.
Now, do a “Search for” to see if you get any result from you database with this constrains:
Store = Current Page Store
Weekday = Current Date/Time Weekday
Open_hour_number < Current Date/Time:Extrat Hours*60 + Current Date/Time:Extrat Minutes
Close_hour_number > Current Date/Time:Extrat Hours*60 + Current Date/Time:Extrat Minutes
If the :count of this Search is > 0, than your store is open.
Would this method work if the hours were like this:
Saturday: 5pm - 2am
if the time were 7pm, the open hour number would be less than the extracted hours + extracted minutes, but the closing hour would also be less than the extracted values, so the search would return empty.
Hey,
how can I set it up so that when the time (opening_time_text) is set to 08:00, my opening_time_number is automatically set to 480? I have created the different options, but I don’t know how to link them together.