Alex Rivera | Logout

Converting MySQL datetime to RSS pubDate using PHP?

Asked 2010-07-25T16:22:47.950
9

i was wondering how would I convert datetime using PHP to work with RSS feeds pubDate?

Why is my browser 3 hours off when displaying the time? Is there a way to correct this?

Edit
Report

2 Answers

5
<pubDate><? echo date("r", strtotime($data["added_on"])); ?></pubDate>

Courtesy of the first google result on 'mysql rss pubdate'

Edit: The off-time is probably due to timezone issues; it's not your browser, probably, it's the time being generated by PHP. Have you configured your PHP instance properly?

Edit: Sorry for the confusion guys, forgot to added the "Edit:" remark. No need to bash on the asker!

answered 2010-07-25T16:24:44.840
4
<?php
$query = mysql_query("SELECT added_on FROM 'table');
while($row = mysql_fetch_array($query)){
?>
<pubDate><? echo date("r", strtotime($data["added_on"]));} ?></pubDate>

As BoltClock used the gmdate you WILL get the time in GMT, so you could calculate where you are easier. That said PHP is server side thus your browser might be +- 3 hours because the server is in a +-3 time zone from your browser. If you are experiencing that problem locally check for weird locales.

answered 2010-07-25T16:55:23.930

Your Answer