Quantcast
Channel: Zend RSS feed pubDate time formatting - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Zend RSS feed pubDate time formatting

$
0
0

Hopefully this is a quick one for someone in the knowledge but i am having a problem trying to get the correct datetime format for an RSS feed in a Zend framework project and exhasuted all avaliable resources; php datetime The only resource I cant fully comprehend is the Zend documentation as Im not quite sure how to correctly call the static class they refer too Zend Date_time. Also the DB field is a datetime type...

I have got as far as getting all my data into the feed with the exception of the pubDate out putting in XML format. As the format is not recognised correctly the feed is just spitting out the current date for each post. Heres as far as I got...

public function rssAction()
{

    $this->_helper->layout->setLayout('xmllayout');

    $model = new Default_Model_News;
$newsitems = $model->fetchAll();
    $date = date("D\, j M Y G:i:s");

    $feedArray = array (
            'title'            =>    "Postgoldforcash News Feed",
            'description'      =>    "Postgoldforcash News Feed",
            'link'             =>    "http://www.postgoldforcash.com",
            'language'         =>    'en-EN',
            'charset'          =>    'utf-8',
            'docs'             =>    "Postgoldforcash News",
            'pubDate'          =>     $date,
            'entries'          =>    array()
        );

    foreach ( $newsitems as $article ) {
    $fDate = date_format(new DateTime($article->publishDate), "r");
        $feedArray['entries'][] = array (
                    'title'           =>    $article->title,
                    'link'            =>    $article->url."/", // for some reason i have to add a blank space or '/' in otherwise it breaks...
                    'guid'            =>    $article->title,
                    'description'     =>    $article->content,
                    'pubDate'         =>    $fDate
            );       
    }
    $feed = Zend_Feed::importArray($feedArray, 'rss');
    $feed->send();
}

I have tried all the other ways of getting the correct formatting including;

 date_format(new DateTime($article->publishDate), "D\, j M Y G:i:s");


strftime ($article->publishDate, "%a, %d %b %Y %H:%M:%S %z") ;


gmdate(DATE_RSS, strtotime($article->publishDate));

Any pointers would be great!


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images