Marwelln
Marwelln

Reputation: 29413

How do I get feed date with Zend Feed?

I'm parsing RSS feed. Everything works fine except I don't know how to get the feed date.

foreach ($sql as $row) {
    try {
        $feed = Zend_Feed::import($row['url']);
    } catch (Zend_Feed_Exception $e) {
        continue;
    }

    foreach ($feed as $item) {
        $title = $item->title();
        $link = $item->link();
        $show = 'yes';
        $date = $feed->pubDate();
        $year = date('Y', $date);
        $month = date('n', $date);
        sqlquery("INSERT INTO rw_feed (
            feed_title, feed_link, feed_show, feed_date, feed_date_year, feed_date_month
        ) VALUES (
            ?, ?, ?, ?, ?, ? 
        )", "sssiis",
        array(&$title, &$link, &$show, &$date, &$year, &$month));
    }
}

pubDate() is not working. Does anyone know what the function is named to get the date?

Upvotes: 0

Views: 269

Answers (1)

ByteNudger
ByteNudger

Reputation: 1561

pubDate() is the right function, but in your code you use the wrong variable. You have to change

$date = $feed->pubDate();

to

$date = $item->pubDate();

Upvotes: 2

Related Questions