How can I override a node's post date theme? HTML5 provides a time element, and a lot of modern sites are using the time element for their content post dates.

How can I override a node's post date theming, so I can change the rendering from a div element to a time element?

Currently, the markup looks like:

&lt;div class="field__item even"&gt;2015-01-17&lt;/div&gt;


I want it to render it as:

&lt;time datetime="2015-01-17T12:00"&gt;2015-01-17&lt;/time&gt;


I would like to handle this in my theme, since I have an Omega 4 subtheme I use as a base theme for client sites and want it to handle the functionality.
I'm using Display Suite, which takes over the node's created timestamp and turns it into a field named post_date.  Therefore, I overrode the field.tpl.php file and named it field--post-date.tpl.php, and added the time element to the markup:

&lt;div class="&lt;?php print $classes; ?&gt;"&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php if (!$label_hidden): ?&gt;
    &lt;div class="field-label"&lt;?php print $title_attributes; ?&gt;&gt;&lt;?php print $label ?&gt;:&amp;nbsp;&lt;/div&gt;
  &lt;?php endif; ?&gt;
  &lt;div class="field-items"&lt;?php print $content_attributes; ?&gt;&gt;
    &lt;?php foreach ($items as $delta =&gt; $item): ?&gt;
      &lt;div class="field-item &lt;?php print $delta % 2 ? 'odd' : 'even'; ?&gt;"&lt;?php print $item_attributes[$delta]; ?&gt;&gt;&lt;time datetime="&lt;?php print $datetime; ?&gt;"&gt;&lt;?php print render($item); ?&gt;&lt;/time&gt;&lt;/div&gt;
    &lt;?php endforeach; ?&gt;
  &lt;/div&gt;
&lt;/div&gt;


To get the $datetime variable, I added the following code to theme_preprocess_field():

function mytheme_preprocess_field(&amp;$vars) {
    // check for Display Suite fields.
    if ($vars['element']['#field_type'] != 'ds') {
        return;
    }
    switch ($vars['element']['#field_name']) {
        case 'post_date':
            if ($vars['element']['#entity_type'] != 'node') {
                break;
            }
            $node = $vars['element']['#object'];
            $vars['datetime'] = date_iso8601($node-&gt;created);
        break;
    }
}


I'm just handling nodes, and a node always has one created time.  The loop in the tpl file can probably be removed, since there will always be one value.