Custom date formats in webform emails I have a webform that sends an email. The webform has a date field and I need to format that date field.

I have tried:

[submission:values:date_field:CUSTOM_FORMAT]
[submission:values:date_field:long]
[submission:values:date_field:value:custom:d-M-y]


Both result in a blank date.

How can I format the date in a webform email using a non-default (which appears to be short) date format?
I had to create a custom hook_tokens function:

/**
 * Implementation of hook_tokens().
 */
function MODULE_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  if ($type == 'submission' &amp;&amp; !empty($data['webform-submission'])) {
    $node = isset($data['node']) ? $data['node'] : node_load($submission-&gt;nid);

    foreach ($tokens as $name =&gt; $original) {
      switch ($name) {
        case 'values:date_field:custom_format':
          foreach ($node-&gt;webform['components'] as $cid =&gt; $component) {
            if ($component['form_key'] == 'date_field') {
              $replacements[$original] = format_date(strtotime($data['webform-submission']-&gt;data[$cid][0]), 'custom_format');
            }
          }
          break;
      }
    }
  }

  return $replacements;
}