I'm working on a project where I have a MYSQL database containing a database table which has opening hours of a load of businesses in it.
Each business has 4 TIME fields for each day in the format 00:00:00 which are named to indicate the weekday i.e MONOPEN1, MONCLOSE1, MONOPEN2, MONCLOSE2, TUEOPEN1.........
My original idea was to output it as a table in the format
Monday
10:00-12:00
14:00-16:00........... obviously showing 4 times per weekday
I then found that I haven't got room for it on my webpage so I decided that the best way would just to give a visual indication as to whether the business is open or closed.
So I had to determine the day:
I managed that using the code:
Expand|Select|Wrap|Line Numbers
- $timestamp = time();
- $day = date("D",$timestamp);
- echo $day;
1. I want to format the times so that they are in the format HH:MM not HH:MM:SS as stored in the mysql database
2. Once I have managed to do that I would like to be able to compare the current time (which I can get using a similar function to the above) to the 4 time values and set another field to "Open" or "Closed" so I can echo it to the screen
I just can't get my head round how to do this as I'm not great with maths and time calculations have just got me totally confused, especially with 4 times to look at each time.
If anyone can help with this I would really appreciate it as I am very new to PHP and MYSQL and am only learning at the moment. I've trawled the web quite a bit to try and work out how to do this and there's so many functions I'm lost!
Thanks
David