0

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!

3
  • Can you show us what you have tried? – AllInOne Mar 1 '17 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 Carleton Mar 1 '17 at 19:15
  • Javascript solution here: stackoverflow.com/questions/36900482/… – AllInOne Mar 1 '17 at 19:45
0

So {current_time format="%l"} yields the current day. Can't you use a conditional based on that?

https://expressionengine.com/forums/archive/topic/195111/help-with-conditional-statement-based-on-current-day-of-the-week

Something like:

{if '{current_time format='%l'}' == "Saturday" OR '{current_time format='%l'}' == "Sunday"}
  CLOSED
{if:else}
  OPEN
{/if}
2
  • 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. – Matthew Carleton Mar 1 '17 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 – Jeremy Mar 4 '17 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.