Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Timed Content Based on the Time of Day AND Day of the Week?

  • xengent
  • xengent
  • OFFLINE
  • Posts: 54
  • Thanks: 2
  • Karma: 0
8 years 10 months ago - 8 years 10 months ago #275592 by xengent
I would like to show content within modules and articles that is based on the time of day and specifically the day of the week (monday, tuesday....).

I would like to use this to show/hide content based on our hours of operation, e.g. having an "Open" and "Closed" sign to show when we are available for support.

Is this possible using CB IF statements? e.g. "if day of the week is Monday and time range is between 9AM & 5PM, show this content"?

Alternatively I looked at trying to show an entire module via the native Joomla publish date feature, but it doesn't seem to be capable of enabling/disabling recurring publish dates, nor is it able to select by day of week.
Last edit: 8 years 10 months ago by xengent.

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
8 years 10 months ago #275609 by nant

xengent wrote: I would like to show content within modules and articles that is based on the time of day and specifically the day of the week (monday, tuesday....).

I would like to use this to show/hide content based on our hours of operation, e.g. having an "Open" and "Closed" sign to show when we are available for support.

Is this possible using CB IF statements? e.g. "if day of the week is Monday and time range is between 9AM & 5PM, show this content"?

Alternatively I looked at trying to show an entire module via the native Joomla publish date feature, but it doesn't seem to be capable of enabling/disabling recurring publish dates, nor is it able to select by day of week.


I published a tutorial a while ago that should help you with this:

www.joomlapolis.com/support/tutorials/107-use-cases/18240-time-released-subscription-content-solution

Please Log in or Create an account to join the conversation.

  • xengent
  • xengent
  • OFFLINE
  • Posts: 54
  • Thanks: 2
  • Karma: 0
8 years 10 months ago #275658 by xengent
Close, but not sure how to specify a day of the week. The article talks about setting a "days difference" from a specific date set, using "greater than" / "equal to".

The only way I would see this working for my use case is by setting 7 dates (any seven consecutive days in the past, one for each day of the week), and then having the statement say "if now is a multiple of 7" for each of those statements, that way the content will be displayed every seven days. For example I would set the date for Tuesday December 15, 2015, and then from that date, any date that is a multiple of 7 would show that content (hence showing it every Tuesday).

Will this work? If so, how do I write the if statement to be a multiple of 7?

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
8 years 10 months ago #275667 by nant

xengent wrote: Close, but not sure how to specify a day of the week. The article talks about setting a "days difference" from a specific date set, using "greater than" / "equal to".

The only way I would see this working for my use case is by setting 7 dates (any seven consecutive days in the past, one for each day of the week), and then having the statement say "if now is a multiple of 7" for each of those statements, that way the content will be displayed every seven days. For example I would set the date for Tuesday December 15, 2015, and then from that date, any date that is a multiple of 7 would show that content (hence showing it every Tuesday).

Will this work? If so, how do I write the if statement to be a multiple of 7?


Well, you need to make changes to the tutorial - I just provided it as a general guideline.

You should be able to use following SQL query to get the day of the week:

SELECT DATE_FORMAT(NOW(),'%w');

That should return a number from 0 to 6 for each day of the week.

You can see this function here:

www.w3schools.com/sql/func_date_format.asp

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum