We have a website, that displays a list of regional offices with their opening and closing times. Part of the design requires that each office is styled to show if its is open or closed.
Our initial thoughts on how to handle this is as follows:
Get the current time {current_time format="%G%i"}
so we have 2033
We then have custom fields for each entry, these are {office_open_time}
and then {office_close_time}
these times are set using GMT (the servers time) so lets take USA as an example 0900 in US time would be 1700 GMT, so the US times we set are:
{office_open_time}
= 1700
{office_close_time}
= 0100
Our template then checks the times:
{if "{current_time format="%G%i"}" <= "{office_close_time}" AND "{current_time format="%G%i"}" >= "{office_open_time}"}
we are open!
{if:else}
we are closed.
{/if}
On the whole this works with a few exceptions and issues.
Again lets say our time here in GMT is 2033. The US opening time set in GMT is 1700 so thats correct, but the closing time is 0100 - so the current time is never less than the closing time..!
Then there's also the issue of the weekend but I think we can do that by returning the date as a day and checking if it equals "saturday" OR "sunday" - however I'm not sure how we decide 'when' that's valid... ie it's saturday in the uk before it's saturday in the us!
Any help or suggestions greatly appreciated