Community Documentation

Show block based on day and time

Last updated September 30, 2009. Created by WorldFallz on September 30, 2009.
Log in to edit this page.

You can specify the day and time a block should be shown as follows:

<?php
$time
= (int) date('Gi');
return (
date('D') == 'Mon' && $time >= 800 && $time <= 1600);
?>

This would display the block every Monday between 8am and 5pm. You can adjust the day and time accordingly using any of php's date and time functions.

Based on http://drupal.org/node/320621.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 5.x, Drupal 6.x
Audience
Developers and coders, Themers

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here