Reputation: 155
I have a PHP bookmarking script I'm using that builds an RSS feed from my bookmarks (script is Semantic Scuttle). Each item in the RSS looks like the below.
<item>
<title>Technology and the Evolution of the Designer’s Role</title>
<link>https://blogs.adobe.com/creativecloud/technology-and-the-evolution-of-the-designers-role</link>
<guid>http://apps.timpaneeze.com/bookmarks/www/#7</guid>
<description>Today, we often associate design with activities like user experience, graphic and web design, or perhaps fashion and product design. Mass communications and mass production brought with them the need for specific skills in creating posters and products. Each wave of technological change brings with it an evolution in the role and activities that designers undertake.</description>
<dc:creator>bobroberts</dc:creator>
<pubDate>Fri, 27 Jan 2017 00:05:50 +0000</pubDate>
<category>design</category>
</item>
The pubdate doesn't match the time I actually create the bookmark in the system, and there's no UI to change it. I found online advice to use strtotime($row['bDatetime']) - 60 * 60 * 14
to change the time (one post was 14 hours off). That is not actually fixing the date, though. For some items the resulting time is correct, but not for others.
I also pull the RSS feed items into WordPress, where the time gets even screwier. WP brought that RSS item in with a future publish time of 26 Jan 2017, 18:05. That WP install is set to Los Angeles (Pacific) timezone.
So, quick recap:
strtotime($row['bDatetime']) - 60 * 60 * 5
doesn't reliably fix every pubDateHow do I make these match up?
Is the +0000 in the pubdate the key? If so, how do I modify that?
The only place the pubdate appears in the bookmarking script files is here. You can see the original line last and my unsuccessful attempt to fix it at the top:
$_pubdate = gmdate('r', strtotime($row['bDatetime']) - 60 * 60 * 14);
/* PSB EDIT Replaced below line with above. */
/* $_pubdate = gmdate('r', strtotime($row['bDatetime'])); */
Upvotes: 2
Views: 128
Reputation: 42716
After some time in the chat room, the question boiled down to converting a MySQL date string to an RFC822 date string, while maintaining the correct time zone. This is the code that ended up working:
$timestamp = strtotime($row["bDatetime"]);
if (date("I", $timestamp) == 1) {
$offset = 25200;
} else {
$offset = 28800;
}
$_pubdate = date("r", $timestamp - $offset);
Upvotes: 1