fechas

Mostrar el tiempo que falta con respecto a la fecha de un campo

// a la hora de pintar un campo llamamos a la función, para que en vez de
//pintar su falor de fecha, pintemos el tiempo que queda para que pase. ejemplo
 
$node = node_load($nid);
$event_start = $node->event_start;
 
   $time = time() - (2 * 60 * 60);
   $minutesleft = floor(($event_start - time()) / 60);
    if ($minutesleft < 0) {
      $timeleft = t('NOW');
    }
    else if ($minutesleft < 60) {
      $timeleft = format_plural($minutesleft, '1 minute', '@count minutes');
    }
    else if ($minutesleft >= 60 && $minutesleft < (24 * 60)) {
      $timeleft = format_plural(floor($minutesleft / 60), '1 hour', '@count hours');
    }
    else if ($minutesleft >= (24 * 60)) {
      $days = floor($minutesleft / (24 * 60));
      // hours remainder
      $hours = ($minutesleft % (24 * 60)) / 60;
      // hours left in the day
      $hours_left = 24 - date('G', time());
      if ($hours > $hours_left) {
        $days++;
      }
      $timeleft = format_plural($days, '1 day', '@count days');
    }
    $node->timeleft = $timeleft;
    $ctype = module_invoke('flexinode', 'load_content_type', substr($node->type, 10));
    $time = $timeleft;
    if ($time == 'AHORA'){$tiempo= '<div class="block_tiempo">'.'(Esta siendo ' .$time.')'.'</div>'; }
    elseif ($time=='1 día'){$tiempo='<div class="block_tiempo">'.'(falta '.$time.')'.'</div>';}
    else {$tiempo= '<div class="block_tiempo">'.'(faltan ' .$time.')'.'</div>';}
 
return $tiempo;

Pintar 1 campo de tipo fecha en un calendario

// En el tpl.php
<? 
  $fecha_1=explode ('T', ($node->field_dia_y_hora[0]['value']));
  $fecha=explode ('-', $fecha_1[0]);
  $fecha = mktime(0, 0, 0, $fecha[1], $fecha[2], $fecha[0] );
?>
  <span class="post-month"><?php print (date('M', $fecha)) ?></span>
  <span class="post-day"><?php print (date('d', $fecha)) ?></span>
/* sytle.css */
.post-date-agenda {
  float:left;
  width:55px;
  height:40px;
  margin-right:10px;
  border-right:1px dotted #ccc;
  background-image: url(images/calendario1.png);
  background-repeat:no-repeat;
  background-position:left top;
}
 
.post-date-agenda .post-month {
  display:block;
  margin-left:0px;
  padding-top: 5px;
  font-size: 8px;
  line-height: 10px;
  text-transform: uppercase;
  text-align: center;
  color: #fff;
}
.post-date-agenda .post-day {
  display:block;
  margin-left:0px;
  padding-top: 2px;
  font-size: 14px;
  font-weight:bold;
  text-transform: uppercase;
  text-align: center;
  line-height: 18px;
  color: #333;
}

Distribuir contenido
Diseño y desarrollo INVESTIC con DRUPAL