John Magnolia
John Magnolia

Reputation: 16793

PHP strtotime not working with Zend_Feed always displaying todays date

The problem seem to be caused with Zend_Feed always changing the publish date to today's date/time.

foreach($array['rss']['rows'] as $row) {
    try {
        $pubDate = strtotime($row['from']['value']); 
        $entry = array(
            'title'       => "{$row['title']['value']}",
            'pubDate'    => "{$pubDate}",
            'link'        => "{$url}news/item/{$row['uri']['value']}",
            'description' => "{$row['content']['fvalue']}"
        );

        array_push($this->entries, $entry);
    } catch(Exception $e) {
        throw($e);          
    }
}   

$rss = array(
    'title'   => 'News',
    'link'    => $url,
    'description' => 'Latest News Articles',
    'charset' => 'ISO-8859-1',
    'entries' => $this->entries
);

$feed = Zend_Feed::importArray($rss, 'rss');
$feed->send();

The from value is formatted like this 2012-05-07 00:00:00. When I var_dump the $rss array just before it is passed to the Zend_Feed I get:

array(4) {
  ["title"]=> string(44) "International Horse Trials"
  ["link"]=> string(31) "http://www.horse.co.uk/"
  ["description"]=> string(78) "Location: Wetherby "
  ["pubDate"]=> string(10) "1339023600"
}

I have tried every combination I can think of to get the date to work in different formats.

$pubDate = gmdate(DATE_RFC822, strtotime($row['from']['value']));

Upvotes: 0

Views: 368

Answers (1)

Ashley
Ashley

Reputation: 5947

You're using the wrong variable:

'lastUpdate' => 'timestamp of the publication date',

http://framework.zend.com/manual/en/zend.feed.importing.html

Upvotes: 3

Related Questions