I have a custom node.tpl.php and I am trying to figure out how to print the date. I have a field_born cck date field, and would like to figure out the correct way to have this printed. Thanks.

Comments

Arkrep’s picture

Issue tags: +CCK, +date

Just in case anyone else comes across this page.

To access the raw cck date in the node.tpl.php

print $node->field_cck_dob[0]['value']

To format date.

  $date_raw = $node->field_rcck_dob[0]['value'] ; 
  $date_object = date_make_date($date_raw); 
  $formatted_date = date_format_date($date_object,'medium'); // Medium is set up in /admin/settings/date-time/formats
  print $formatted_date;

Source: http://drupal.org/node/295105

Arkrep’s picture

After more research there is a much easier way of displaying a date cck field in a node template..

print content_format('field_date_dob' . $field_date_dob[0]); 

source http://drupal.org/node/92382

Please note:
When using this method with the Devel development module enabled and there is no To date selected the From date will be displayed twice.

pglynn’s picture

I've used the following to display the date field in a node template as well:

print $node->field_cck_date[0]['view'];
choster’s picture

Category: task » support
Status: Active » Closed (fixed)
Issue tags: +date format

Several suitable alternatives give, closing.