Skip to content

Instantly share code, notes, and snippets.

@arnalyse
Created May 7, 2013 13:10
Show Gist options
  • Save arnalyse/5532442 to your computer and use it in GitHub Desktop.
Save arnalyse/5532442 to your computer and use it in GitHub Desktop.
shows how to get the correct UTC time with no offset out of a Wordpress post
<? php
/*
WORDPRESS: Howto get the UTC time of a post without an offset
source: http://codex.wordpress.org/Template_Tags/get_post_time
- the 'c' formats datetime string in ISO8601
- the 'true' advises Wordpress to calculate the UTC/GMT
instead of the timezone defined in Wordpress
from wp-includes/general-template.php:
function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false )
note: other functions rely on this one, like 'the_time' and 'get_the_time',
*/
get_post_time('c', true)
get_post_modified_time('c', true)
?>
@zalog
Copy link

zalog commented Oct 4, 2015

And this is how should looks the time html5 tag:

<time itemprop="dateCreated" datetime="<?php echo get_post_time('c', true);?>"><?php the_date(); ?></time>

of course for any timezone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment