Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Subscribe to WebmasterWorld
Storing business hours in database ocon msg:4433224 4:54 pm on Mar 25, 2012 (gmt 0) I have a large database of different businesses around the world that I would like to include their business hours. I'm wondering how to best store their hours in the database. I would like to be able to nicely output their hours on my website, something like: Sun: Closed Mon-Fri: 7AM-9PM Sat: 10AM-6PM Sun-Sat: 24hrs Sun: Closed Mon: 12PM-6PM Tue: Closed Wed: 10AM-12PM, 3PM-7PM Thu-Sat: 12PM-7PM While at the same time I am looking to be able to perform database queries to search for businesses that are currently open. Right now a single row on one table is all that is needed for each listing and ideally I would like to keep it that way. While I don't want to display it on the website, I also realize for things like performing the currently open searches, I need to somehow account for different timezones.
g1smd msg:4433238 6:24 pm on Mar 25, 2012 (gmt 0)
Firstly, use 24 hour time. It will make things a lot easier. You'll also need a list of places that observe DST and the dates that apply for each one... otherwise your "open now" indicator will be off by an hour for 5 to 7 months of the year.
topr8 msg:4433242 7:24 pm on Mar 25, 2012 (gmt 0)
either have 4 fields for each day. first open,first closed, second open, second close (that's assuming that shops only ever (potentially) close for lunch and not twice a day) so you have an extra 28 fields in the table per store then build a php function to calculate the opening times on the page. or. there can only be so many open/close sequences. create an extra table with one row for each variation and reference the id field in your businesses table.