Support » Fixing WordPress » How do I include date on fetch_rss?

  • Resolved WPChina


    I am fetching an RSS2.0 feed from a wordpress blog and I want to integrate it into my site. I am using pubDate to try to get the date of the feed on my site, but pubDate seems not to work. I can get the title and the URL, but not the date.

    Anyone know how to print the date for posts from the fetched feed? In addition, is it possible to capture other info from that fetched feed when using fetch_rss?


Viewing 6 replies - 1 through 6 (of 6 total)
  • Try ‘pubdate’, not ‘pubDate’.



    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);



    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:

    require_once(ABSPATH . WPINC . '/rss-functions.php');
    $rss = fetch_rss('');
    for($i=0;$i<5;$i++) {
    $pubdate=substr($item['pubdate'], 0, 16);
    echo '<p><a href="'.$item['link'].'" title=" '.$item['title'].'">
    <br>'.$item['description'].'<a href="'.$item['link'].'">

    Moderator Samuel Wood (Otto)

    (@otto42) Admin


    Change that to:



    ahhhhhh…. works well…. tks!

    I will now mark this Resolved!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I include date on fetch_rss?’ is closed to new replies.