Add a date token

As we already said, the date token is different from the text one.

Take a look at the ARTICLE_PUBLISH_UP token in the token list: it's like a regular one, but its type is date.

So far so good, ok? Now move to the template override and search for it. As you can see it's quite different from the other ones.

Example 5.3. Date Token

<time { ARTICLE_PUBLISH_UP:<?php echo $this->item->publish_up?> }>
   <?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', 
              JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC2'))); ?>
</time>

As you can see, we have to wrap the text we want to style with a time tag, then add the token to it.

The token syntax is quite different, since we have to pass to the plugin the date in order to transform it into the ISO format. To do that we have to add a colon (:) after the token name, then output the date value.