Zend RSS feed pubDate time formatting

I hope this is quick for someone who knows, but I had a problem trying to get the correct date and time format for the RSS feed in the Zend framework project and display all available resources; php datetime The only resource I cannot fully understand is the Zend documentation, as I am not quite sure how to properly call the static class to which they refer. Zend Date_time . Also the DB field is a type of date and time ...

I got to all my data in the feed, except for publishing pubDate in XML format. Since the format is not recognized correctly, the feed simply splashes out the current date for each message. Heres, as I understand it ...

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

, :

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

!

+3
2

pubDate . .

'lastUpdate' = > strtotime ($ article- > publishDate) $feedArray. , Zend RSS gmdate .

importBuilder.

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

( ive 10)

, :

    public function rssAction() {

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

    $model = new Default_Model_News;
    $newsitems = $model->fetchAll();
    $date = date("YYYY-MM-dd HH:mm:ss");

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

    $i = 0;
    foreach ($newsitems as $article) {
        $i++;
        if ($i > 10)
            break;
        $feedArray['entries'][] = array(
            'title' => html_entity_decode($article->title),
            'link' => $article->url ."/",
            'guid' => $article->url,
            'description' => strip_tags($article->content),
            'lastUpdate' => strtotime($article->publishDate)

        );
    }
    $feed = Zend_Feed::importBuilder(new Zend_Feed_Builder($feedArray), 'rss');
    $feed->send();
}

.

+4

RFC_2822. :

$fDate = new Zend_Date();
foreach ( $newsitems as $article ) {
    $date->set($article->publishDate, 'YYYY-MM-dd HH:mm:ss');
    $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'       => $date->get(Zend_Date::RFC_2822)
    );       
}
+1

Source: https://habr.com/ru/post/1794522/


All Articles