Converting a timestamp to PHP date format for a field in a node template I have an imagefield, 'event_image' and printing all possible variables for the field tells me I have timestamp as a possible variable of the image to render. I use:

print '&lt;pre&gt;';
var_dump(get_defined_vars());
print '&lt;/pre&gt;

// renders:
["timestamp"]=&gt;
string(10) "1348629688"


... in node--mycustom.tpl.php to get the variables. 

Now I can render the timestamp as such:

&lt;?php print $node-&gt;field_event_image['und'][0]['timestamp'] ?&gt;


... and it prints a UNIX formatted timestamp as:

1348629688


I'd like to convert this to a PHP date format. So I am guessing I would need to convert the UNIX timestamp somehow using the PHP gmdate function. Typically I would use something like this for raw php:

  $mytimestamp=1348629688;
  print gmdate("m-d-Y", $mytimestamp);


Which would take my timestamp and output:

09-26-2012


... but I just don't know how to do within the context of my drupal 7 field and the node template.

UPDATE:

Base on clive's comment below, it turns out a preprocess function is the way to go:
So in my theme's template.php file I now have:

function MYTHEME_preprocess_node(&amp;$vars, $hook) {

$node = $vars['node'];
$field_items = field_get_items('node', $node, 'field_event_image');
$vars['upload_date'] = format_date($field_items[0]['timestamp'], 'mdy');

}


... and then in my custom node template, I have:

&lt;?php print $upload_date; ?&gt;


Note, 'mdy' is a custom format I set in the Drupal UI. That's better than using gmdate I suppose.
As already pointed out by  Mohammed Shameem:

&lt;?php print gmdate("m-d-Y", $node-&gt;field_event_image['und'][0]['timestamp']) ?&gt;


However, the Drupal way would be:

&lt;?php print format_date($node-&gt;field_event_image['und'][0]['timestamp'], 'short'); ?&gt;


The latter construct will render the date in the standard short date format set up for the site.  The former will use the format you pick.  The Drupal way ensures that the date format is standardized throughout the site.