I had the need to convert a MySQL datetime time stamp into a format accepted by the RSS 2.0 specification. To get the first part, you can do a SQL query like the following:
1 | SELECT DATE_FORMAT(dateTimeColumn, '%a, %d %b %Y %T') AS rssPubDate FROM yourTable |
After that, you need to get the timezone, which can be accomplished by using this:
1 | $timeZone = date('T'); |
So lets say you store the rssPubDate from MySQL in a variable called $rssPubDate, all you need to do is $rssPubDate .= ” {$timeZone}”;
That’s it! You now have a RFC-822 compliant time stamp.
5 replies on “Converting MySQL dateTime to RFC-822 (RSS pubDate) in PHP”
I want to ask how to store the rss pubdate in mysql , and which mysql datatype is used for storing pubdate in the DB.
I would store it as datetime.
Sorry, I’m newbie about everything in MySQL, how I suppose to do that? I mean editing it. Thanks.
I’m not really sure what you’re asking for. Edit what?
I’ve been scouring the web for hours searching how to do that. Thanks!!!