Well, you are right about the 12-hour clock for the hours - my only excuse is that I copy/pasted from Wrathy's code.
But I wish you would all stop trying to upsatge me on the control structure, especially with if/else's. If you would read the manual you would understand how switch works and why it is better than a load of ifs.
"It is important to understand how the switch statement is executed in order to avoid mistakes. The switch statement executes line by line (actually, statement by statement). In the beginning, no code is executed. Only when a case statement is found with a value that matches the value of the switch expression does PHP begin to execute the statements. PHP continues to execute the statements until the end of the switch block, or the first time it sees a break statement. If you don't write a break statement at the end of a case's statement list, PHP will go on executing the statements of the following case."
AND
"In a switch statement, the condition is evaluated only once and the result is compared to each case statement. In an elseif statement, the condition is evaluated again. If your condition is more complicated than a simple compare and/or is in a tight loop, a switch may be faster."
Now, obviously, in my use I am evaluating an expression for each case, so the speed advantage is diminished. Even so, yours will require the evaluation of at least 2 expressions for the IF and 3 or 4 for the ELSE - while mine is 1 for the first case and just 2 for the second and third cases.
The switch also is better because it is more logical, and more legible and far less likely to introduce a bug if it needs to be amended with new conditions/cases.
Houdini your time calculation is cool, but again it's logic is not obvious and any amendment is likely to introduce a bug unless it is thoroughly well documented.
[edit]No it's not, it does not work for times between midnight and opening hour. See what I mean about obtuse code. So your solution needs another elseif to account for that case (midnight to 9:30 AM). Even less satisfactory than the switch.[/edit]
Now I know everyone is going to say "What do you mean introduce a bug? Should be obvious to an experienced coder.". This thread is all about an inexperienced coder having to maintain and update someone elses code because the guy left. Clear, concise, self documenting code that can be easily maintained by anyone else is the mark of a good proffessional software engineer - everything else is just hacking, no matter how slick the algorithm may be.