The time element and WordPress

Wordpress and the Time Element

I’m currently in the process of re-designing this site and part of this process means updating it to utilise the latest HTML5 and CSS 3 elements where possible, and as a result of this I’ve used the time element in all dates such as post date and also other dates.

The format of the time element for dates is as follows:

<time datetime="2009-11-13">13 November 2009</time>

The datetime attribute has to contain an ISO 8601 date although the value can contain any date format you wish. When using this with the dynamic nature of wordpress, the following format produces a valid output for post dates:

<time datetime="<?php the_time('c'); ?>"><?php the_time('F jS, Y'); ?></time>

This will currently produce valid HTML5 and can be used in addition to “pubdate” to indicate that this was the date the article was published.

<time datetime="<?php the_time('c'); ?>" pubdate><?php the_time('F jS, Y'); ?></time>

Of course, time can be used elsewhere on the site where suitable, and in any string format you wish.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

RSS Icon