Try ‘pubdate’, not ‘pubDate’.
Thread Starter
WPChina
(@wordpresschina)
Great, fixed… almost….
It now prints something like this: “Thu, 16 Nov 2006 01:47:42 +0000”
But is it possible to only get it to print “Thu, 16 Nov 2006”?
Thank you Kafkaesqui!
The simplest way is, since the format is always the same and the character count shouldn’t vary, is to parse it using the PHP substr() function.
Assuming each rss item is held in $item
in your code:
$pubdate = substr($item['pubdate'], 0, 16);
Thread Starter
WPChina
(@wordpresschina)
Sorry to bother you, but I can’t figure out where to add that substr. I am using different variations of the following and putting it all different places, but it seems not able to print out the correct info:
<?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
$rss = fetch_rss('http://www.website.com/feed/');
for($i=0;$i<5;$i++) {
$item=$rss->items[$i];
$pubdate=substr($item['pubdate'], 0, 16);
echo '<p><a href="'.$item['link'].'" title=" '.$item['title'].'">
<b>'.$item['title'].'</b></a><br><i>'.$item['pubdate'].'</i>
<br>'.$item['description'].'<a href="'.$item['link'].'">
more...</a></p>';
}
?>
...<i>'.$item['pubdate'].'</...
Change that to:
...<i>'.$pubdate.'</...
Thread Starter
WPChina
(@wordpresschina)
ahhhhhh…. works well…. tks!
I will now mark this Resolved!