I am wondering if I have the ability out of the box to control the date form displayed in the web form and in the email. I more prefer format like
"1/30/2008" instead of "Jan 30 2008".

Do I have to change the code by myself to implement this? Thanks!

Comments

quicksketch’s picture

You can over ride the theme functions for outputting the date. In your template.php file, copy the theme_webform_date() and theme_webform_mail_date() functions from date.inc. Then rename the functions to phptemplate_webform_date() and phptemplate_webform_mail_date(). Change the code however necessary to output the way you like and Drupal will use these functions from your theme instead of webform.

xqi’s picture

Hi quicksketch,

Thanks for the super fast reply. It worked for me.

quicksketch’s picture

Status: Active » Fixed

Woot!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

rgraves’s picture

How can this be accomplished in Drupal 6? I put the following code in my template.php file so that I can format the date as 'September 15, 2009' instead of '09/15/2009' and it's not working.

function phptemplate_webform_mail_date($data, $component) {
  $output = $component['name'] .':';
  if ($data[0] && $data[1]) {
    $timestamp = strtotime($data[0] .'/'. $data[1] .'/'. $data[2]);
    $format = webform_date_format('long');
    $output .= ' '. date($format, $timestamp);
  }

  return $output;
}