How to display panes/views/blocks based on time of day and day of week? Building a D7 site, I need to be able to automatically enable/disable Panel panes and/or views (or in the worst case scenario blocks) based on the time of day - different contact info for out-of-office hours and some other stuff. I also need to display drastically different sets of panes and views on the frontpage based on the day of week.

My temporary solution is to set up a number of Panels pages (for changing panes/views) and duplicate themes (for changing blocks) and run cronjobs with Drush's variable-set to change frontpage from one Panel page to another and to change theme to the one with different blocks enabled.

As simple as the above is, it's a terrible long-term solution because all other, unrelated changes made to the site then often require being made more than once and it's really hard to keep track of.

So is there a more straightforward way to configure per-pane, per-view or per-block setting to get enabled/disabled based on time of day / day of week?
Oddly enough, it doesn't look like any of the Date modules integrate with ctools for selection rules.

I think you have two options, that are essentially the same thing.


Panel page variants support PHP code selection rules.
Panels panes support PHP code visibility rules.


So, your page(s) could have variants based on date/time, and each variant could have panes that are only visible based on date/time.

Your PHP selection rules will use time and/or date.  For example, this should set a rule to only select or be visible on Monday.

$now = time();
$day = date("D", $now);
return $day == "Mon";


The date function does default to the current time, but explicitly using a $now parameter can prevent problems when you call date multiple times when you cross midnight.