How do I make block only visible if the 'field_date_value' is in the past?
Pretend you need a block to be visible on a node depending on the value of a date field on the node.

A good example is a website that lists classes as nodes. You want a block visible only on class nodes. You also only want that block visible if the date of the class is in the future.

The classes are created by making nodes of a custom content type called "class". Each class node contains an date field called "class_date" that contains the date of the first day of the class. The date field is a regular ISO date field type. This PHP snippet returns TRUE if the node is a "class" and the "class_date" field is in the future and the block is then visible.

&lt;?php
$node = menu_get_object();
if ( !empty($node)  &amp;&amp; $node-&gt;type == 'class' ) {
  if ( !empty($node-&gt;field_class_date) &amp;&amp; !empty($node-&gt;field_class_date['und']) &amp;&amp; !empty($node-&gt;field_class_date['und'][0]) ) {
     $parts = explode('T', $node-&gt;field_class_date['und'][0]['value']);
     $date_parts =  explode('-', $parts[0]);
     $class_date = $date_parts[1] . '/' . $date_parts[2] . '/' . $date_parts[0] . ' ' .  $parts[1];
     $on = strtotime($class_date);
     $now = time();
     if ( $on &gt;= $now ) {
        return TRUE;
     }
  }
}
return FALSE;
?&gt;