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