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?
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>
You can use the DateTime class as follows:
$objDate = new DateTime($itemDate);
$rssDate = $objDate->format(DateTime::RSS);
Where $row['date'] is the date from your row in MySQL. $rssDate with contain the properly formatted RSS Date.
<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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With