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?
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?
<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!
Use strtotime()
to convert it into Unix timestamp then convert it into desired format using date()
Assuming $row
is the resultant row of mysql_fetch_assoc()
of your result, and your date column is called date
:
<pubDate><?php echo gmdate(DATE_RSS, strtotime($row['date'])); ?></pubDate>
<?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.