Formatting WordPress the_date or get_the_date for HTML5 time tag (datetime attribute)

This is how you format post dates for the datetime attribute of the HTML5 <time> tag:

<time datetime="<?php the_date('Y-m-d\TH:i'); ?>"><?php the_date(); ?></time>

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>