In my node.tpl.php I use this code (stripped for this topic), to display the node creation date:

  <?php $submitted = 'Heerlen - ' . format_date($node->created, 'custom', 'd.m.Y') . ' - Marc Bijl'; ?>
  <?php print '<div class="small">'. $submitted . '</div>'; ?> 

And the date shows up correct, e.g. 04.01.2009

However, if I use exactly the same code in the body of a node (with php allowed), it shows up as 01.01.1970.

Any ideas?

Comments

nevets’s picture

$node is not define in within the body of a node so $node->created would always be zero (which corresponds to 01.01.1970).

Marc Bijl’s picture

Hi Steve,

Thnx for the quick reply ;)
Do you know if there's a workaround to get the nodes date created from within the body?

Cheers,
Marc

___________________
discover new oceans
lose sight of the shore

nevets’s picture

Sure, but it only works when viewing a single node (i.e. at the path node/{nid})

<?php
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
  $node = node_load(arg(1));
  // You now have access to $node
}
?>

Also see: http://drupal.org/project/reptag

Marc Bijl’s picture

Thanks mate,
I'll try it tonight!

___________________
discover new oceans
lose sight of the shore

Marc Bijl’s picture

You just made my day!

Don't have a clue what the code means/does,
but it works like a charm. Neat...

Many thanks,
Marc

___________________
discover new oceans
lose sight of the shore