Title: HTML5 time pubdate format?
Last modified: August 21, 2016

---

# HTML5 time pubdate format?

 *  Resolved [christianready](https://wordpress.org/support/users/christianready/)
 * (@christianready)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/html5-time-pubdate-format/)
 * I am trying to format my Tweets as proper HTML5 `<article>` elements, e.g.:
 *     ```
       <article>
       <figure><img src="myavatar.jpg></figure>
       <p class="my-tweet">My tweet goes here</p>
       <footer><time pubdate datetime="2013-09-21T09:00:23Z">Sep 21 2013 12:23am</time></footer>
       ```
   
 * Does anyone know how would I get the date and time of the tweet into that ISO
   format for the datetime attribute? Thanks!
 * [http://wordpress.org/plugins/latest-tweets-widget/](http://wordpress.org/plugins/latest-tweets-widget/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/html5-time-pubdate-format/#post-4090435)
 * See the `latest_tweets_render_date` filter hook – example in the [Other Notes tab](http://wordpress.org/plugins/latest-tweets-widget/other_notes/).
 *  Thread Starter [christianready](https://wordpress.org/support/users/christianready/)
 * (@christianready)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/html5-time-pubdate-format/#post-4090449)
 * Thanks. i was looking at that yesterday and I thought I was doing this correctly,
   but I cannot seem to get a value for the datetime attribute to render. I basically
   took your example and added an additional filter:
 *     ```
       add_filter('latest_tweets_render_date', function( $created_at ){
       	$datetime = DateTime::createFromFormat('D M d H:i:s O Y', $created_at );
       	return $datetimeX->format('Y-M-d H:i:s');
       }, 10 , 1 );
   
       add_filter('latest_tweets_render_date', function( $created_at ){
       	$date = DateTime::createFromFormat('D M d H:i:s O Y', $created_at );
           return $date->format('d M h:ia');
       }, 10 , 1 );
   
       add_filter('latest_tweets_render_text', function( $text ){
           return $text; // <- will use default
       }, 10 , 1 );
   
       add_filter('latest_tweets_render_tweet', function( $html, $date, $datetimeX, $link, array $tweet ){
           $pic = $tweet['user']['profile_image_url_https'];
           return '<article class="tweet"><figure class="tavatar"><img src="'.$pic.'"></figure><p class="my-tweet">'.$html.'</p><footer class="my-date"><time pubdate datetime="'.$datetimeX.'"><a href="'.$link.'">'.$date.'</a></footer></article>';
       }, 10, 4 );
   
       add_filter('latest_tweets_render_after', function(){
           return '<footer><a href="https://twitter.com/christianready/">More from me</a></footer>';
       }, 10, 0 );
       ```
   
 * _[Please post code & markup between backticks or use the code button. Your posted
   code may now have been permanently damaged by the forum’s parser.]_
 * To be on the safe side, I even called the value “datetimeX” in case “datetime”
   was a reserved word in PHP. The resulting <time> element looks like <time pubdate
   datetime=””> with no value for the datetime. Any guess as to what I might be 
   doing wrong?
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/html5-time-pubdate-format/#post-4090456)
 * there are two mistakes in that code:
 * 1. you assign $datetime and then attempt to access $datetimeX, which doesn’t 
   exist.
    2. You added $datetimeX as an additional argument to `latest_tweets_render_tweet`.
   It takes 4 only.
 * If you want to write out two separate date values, you’ll have to parse and format
   them again in `latest_tweets_render_tweet` function.
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/html5-time-pubdate-format/#post-4090657)
 * closing after one month with no follow up.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘HTML5 time pubdate format?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/latest-tweets-widget_c5bfab.svg)
 * [Latest Tweets Widget](https://wordpress.org/plugins/latest-tweets-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/latest-tweets-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/latest-tweets-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/latest-tweets-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/latest-tweets-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/latest-tweets-widget/reviews/)

## Tags

 * [datetime](https://wordpress.org/support/topic-tag/datetime/)
 * [html5](https://wordpress.org/support/topic-tag/html5/)
 * [time](https://wordpress.org/support/topic-tag/time/)

 * 4 replies
 * 2 participants
 * Last reply from: [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/html5-time-pubdate-format/#post-4090657)
 * Status: resolved