20 May 2007

Using datetime-design-pattern in WordPress

In WordPress, you can have datetime-design-pattern to publish datetimes that are both a human and machine readable. Apply the example code below in your WordPress template within The Loop replacing the_time or the_date.

Example:

<abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time('F jS, Y g:i a') ?></abbr>

Output:

April 8th, 2008 3:29 am

You can use the table of date format characters on the PHP website as a reference for building date format strings.

Take note, that older version of Internet Explorer doesn’t support <abbr>. Wrap it up with <div> or <span>.