I've seen answers on display content on a specific day, but I'm trying to figure out showing content for Multiple days. I have doctors office that wants to show it's hours Monday-friday and weekend hours. If they are not open they want it to say closed. Thanks for the help!
-
Can you show us what you have tried?– AllInOneMar 1, 2017 at 14:16
-
I'm basically just trying to figure out the most graceful way to code it. I understand that it can be done with multiple conditionals just wondering if I'm missing an obvious way to do more simply.– Matthew CarletonMar 1, 2017 at 19:15
-
Javascript solution here: stackoverflow.com/questions/36900482/…– AllInOneMar 1, 2017 at 19:45
1 Answer
So {current_time format="%l"} yields the current day. Can't you use a conditional based on that?
Something like:
{if '{current_time format='%l'}' == "Saturday" OR '{current_time format='%l'}' == "Sunday"}
CLOSED
{if:else}
OPEN
{/if}
-
This is kind of what I was thinking but I was wondering if there is a more efficient way of doing it. For each of the daily conditionals I'd have to add a second condition of time between 830-430. Mar 1, 2017 at 18:25
-
Not for every single day. You are really just dealing with weekend (Sat/Sun) or NOT weekend (the else). Then write a conditional that checks if current time is greater than opening and less than closing, the it's "open". More here: stackoverflow.com/questions/13228346/conditional-based-on-time– JeremyMar 4, 2017 at 4:14