{"id":2526,"date":"2014-11-01T14:40:06","date_gmt":"2014-11-01T21:40:06","guid":{"rendered":"https:\/\/wysz.com\/wyszdom\/?p=2526"},"modified":"2014-11-01T14:40:06","modified_gmt":"2014-11-01T21:40:06","slug":"datetime","status":"publish","type":"post","link":"https:\/\/wysz.com\/wyszdom\/2014\/11\/datetime\/","title":{"rendered":"datetime"},"content":{"rendered":"<p>On recent weekends, I&#8217;ve been playing around with my blog. I&#8217;m not an engineer, so working on my site is a time when I get to try my hand at basic coding. One thing that most of you have probably noticed is that my blog was returning the incorrect value for the\u00a0datetime attribute\u00a0on posts. I apologize for any inconvenience that this has caused my readers. Specifically, my site\u00a0was displaying\u00a0the PDT time as if it were UTC. On my previous post, you would see something like this:<\/p>\n<pre>&lt;time class=\"entry-date\" datetime=\"2014-10-31T22:01:56+00:00\"&gt;October 31, 2014 10:01 pm&lt;\/time&gt;<\/pre>\n<p>Weird, huh? Doesn&#8217;t that indicate\u00a0that it was posted at 3 PM in California? After reading <a href=\"http:\/\/codex.wordpress.org\/Formatting_Date_and_Time\">how to format the date and time<\/a>, I ended up manually creating what I think &#8216;c&#8217; <em>should<\/em> return by doing this in my functions.php file:<\/p>\n<pre>esc_attr( get_the_date( 'Y-m-d\\TH:i:sT' ) )<\/pre>\n<p>That seemed to do the trick. Now that same post looks like this:<\/p>\n<pre><span class=\"html-tag\">&lt;time <span class=\"html-attribute-name\">class<\/span>=\"<span class=\"html-attribute-value\">entry-date<\/span>\" <span class=\"html-attribute-name\">datetime<\/span>=\"<span class=\"html-attribute-value\">2014-10-31T22:01:56PDT<\/span>\"&gt;<\/span>October 31, 2014 at 10:01 pm<span class=\"html-tag\">&lt;\/time&gt;<\/span><\/pre>\n<p>For comprehensiveness, here&#8217;s what I currently have. It might be helpful for someone else or for me to refer\u00a0to later. I&#8217;ve certainly benefited from others sharing their code. \u00a0And yeah, I know that I&#8217;m calling stuff that I&#8217;m not using but I didn&#8217;t want to change the numbers around:<\/p>\n<pre>\/\/ Set up and print post meta information.\n printf( '&lt;span class=\"entry-date\"&gt;&lt;a href=\"%1$s\" rel=\"bookmark\"&gt;&lt;time class=\"entry-date\" datetime=\"%7$s\"&gt;%3$s at %6$s&lt;\/time&gt;&lt;\/a&gt;&lt;\/span&gt; &lt;span class=\"byline\"&gt;&lt;span class=\"author vcard\"&gt;By &lt;a class=\"url fn n\" href=\"\/about\/\" rel=\"author\"&gt;%5$s&lt;\/a&gt;&lt;\/span&gt;&lt;\/span&gt;',\n esc_url( get_permalink() ),\n esc_attr( get_the_date( 'c' ) ),\n esc_html( get_the_date() ),\n esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),\n get_the_author(),\n esc_html( get_the_time() ),\n esc_attr( get_the_date( 'Y-m-d\\TH:i:sT' ) ) \/\/ Did this because using c as per the template default was returning the local time without correctly specifying the offset or timezone, so I did the formatting manually after reading http:\/\/codex.wordpress.org\/Formatting_Date_and_Time\n );<\/pre>\n<p>Let me know in the comments if I was misinterpreting the old behavior as a bug.<\/p>\n<p><strong>Update on February 22nd, 2015:<\/strong> The Twenty Fifteen theme uses a function called\u00a0<a href=\"http:\/\/koru.synology.me\/2015\/01\/10\/custom-meta-in-twenty-fifteen\/\">twentyfifteen_entry_meta<\/a>. To get this to work, copy that function from \/wp-content\/themes\/twentyfifteen\/inc\/template-tags.php over to functions.php in your child theme. Then replace\u00a0any parameter set to &#8216;c&#8217; to &#8216;Y-m-d\\TH:i:sT&#8217; instead.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On recent weekends, I&#8217;ve been playing around with my blog. I&#8217;m not an engineer, so working on my site is a time when I get to try my hand at basic coding. One thing that most of you have probably noticed is that my blog was returning the incorrect value for the\u00a0datetime attribute\u00a0on posts. I &hellip; <a href=\"https:\/\/wysz.com\/wyszdom\/2014\/11\/datetime\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">datetime<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,8],"tags":[],"class_list":["post-2526","post","type-post","status-publish","format-standard","hentry","category-geek","category-meta"],"_links":{"self":[{"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/posts\/2526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/comments?post=2526"}],"version-history":[{"count":0,"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/posts\/2526\/revisions"}],"wp:attachment":[{"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/media?parent=2526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/categories?post=2526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wysz.com\/wyszdom\/wp-json\/wp\/v2\/tags?post=2526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}