我正在使用 PHP 向我的网站调用 RSS 提要。目前,我下面的代码正在调用 pubDate 的全部内容:
<pubDate>Thu, 12 Sep 2013 07:23:59 +0000</pubDate>
如何仅显示上述示例中的日期和月份,即 9 月 12 日?
编辑
我应该澄清一下,上面的代码行是我目前得到的一个示例输出,但是当我从 RSS 提要中调用最新的 3 篇文章时,这个日期和时间会有所不同。因此,我需要代码更加动态(如果这是正确的术语!)
这段代码是我获取 RSS 提要内容的完整代码:
<?php
$counter = 0;
$xml=simplexml_load_file("http://tutorial.world.edu/feed/");
foreach ($xml->channel->item as $item) {
$title = (string) $item->title; // Title Post
$link = (string) $item->link; // Url Link
$pubDate = (string) $item->pubDate; // date
$description = (string) $item->description; //Description Post
echo '<div class="display-rss-feed"><a href="'.$link.'" target="_blank" title="" >'.$title.' </a><br/><br/>';
echo $description.'<hr><p style="background-color:#e4f;">'.$pubDate.'</p></div>';
if($counter == 2 ) {
break;
} else {
$counter++;
}
} ?>