How to format CCK fields printed in custom template I have managed to print date and dollar amount CCK fields on a custom print.tpl.php template file (associated with the Printer, email and PDF versions module), but they are showing up in a different format than how I have them displayed in the CCK field itself.

The date is showing up like this:  2012-06-01 00:00:00
Instead of like this: June 1, 2012

And the dollar amount is showing up like this: 10000
Instead of like this: $10,000

Here are the code snippets:

    &lt;?php if(isset($node-&gt;field_invoice_due_date['und'][0]['value'])) { 
          print $node-&gt;field_invoice_due_date['und'][0]['value'];
   }
 ?&gt;


    &lt;?php if(isset($node-&gt;field_invoice_amount_to_bill['und'][0]['value'])) { 
          print $node-&gt;field_invoice_amount_to_bill['und'][0]['value'];
   }
 ?&gt;


Can anyone direct me on how I can change those two snippets to output their values in the formats I need?

Thanks!
You'll need to preprocess these elements into the template and format them to the way you want.

Let's take this practical example.  Let's say we have a content type of 'blog' and we wanted to preprocess the same variables as above to be used in the template file...

/**
 * Preprocess variables for node.tpl.php
 *
 * @see node.tpl.php
 */
function theme_preprocess_node(&amp;$vars) {
  if ($vars['type'] == 'blog') {
    if (isset($vars['field_invoice_due_date'][0]['value'])) {
      // Makes June 1, 2012 format from the time provided
      $vars['date_format'] = date("F j, Y", strtotime($vars['field_invoice_due_date'][0]['value']));
    } else {
      $vars['date_format'] = '';
    }
    if (isset($vars['field_invoice_amount_to_bill'][0]['value'])) {
      // you can use whatever function to format the money value, this is just an example.
      $vars['amount_to_bill'] = "$". number_format('%i', $vars['field_invoice_amount_to_bill'][0]['value']);
    } else {
      $vars['amount_to_bill'] = '';
    }
  }
}


if your moving these fields into a custom template, than you can preprocess with this hook as well:

 /**
 *
 * Implements hook_preprocess
 *
 * @param $variables
 * @param $hook
 */
function hook_preprocess(&amp;$variables, $hook) {
  if ($hook == 'custom_template') {
    // do your preprocess magic here, you can find the variables by either dsm() or print_r()
  }
}


then, in the template do this:

&lt;?php print $date_format; ?&gt;
&lt;?php print $amount_to_bill; ?&gt;