ISO 8601 timestamp in WordPress and Php
I’m trying to create a new version of Kubrik WordPress template, compliant to Microformats hAtom. To do this I need to output a timestamp compliant to the ISO 8601 standard, defined in the RFC 3339. It’s not easy as it should be…
Microformats code for the timestamp of this post should be: <abbr class="published" title="2008-01-29T11:42:00+01:00'); ?>">January 29, 2008, 11:42 am</abbr>, where 2008-01-29T11:42:00+01:00 is the ISO 8601 timestamp.
WordPress has not a founction that outputs a standard ISO 8601 timestamp.
The date and time when a post has been published can be called using WP functions the_time and the date, that follow php rules.
The best result you can achieve using default WP 2.3.1/Php commands is 2008-01-29T11:42:00+0100, without : in the time-offset (+0100 should be +01:00).
<abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO'); ?>"><?php the_date(); ?>, <?php the_time(); ?></abbr>, that is the default DATE_ISO8601 datetime constant, as defined on pear. So, if you want this result, it’s better to use <?php the_time(DATE_ISO8601); ?>.
But now the question is which is the correct ISO 8601 timestamp? 2008-01-29T11:42:00+01:00 or 2008-01-29T11:42:00+0100?
Bibliography
- Jukka “Yucca” Korpela, Info on ISO 8601, the date and time representation standard, IT and communication website, section Norms, standards and protocols, 2007-07-07.
- Markus Kuhn, A summary of the international standard date and time notation.
Tag: gmt, iso 8601, Microformats, offset, php, rfc 3339, standard, template, timestamp, WorPress






Lascia un Commento