I have next rss:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Новини на tsn.ua</title>
<link>http://tsn.ua/</link>
<description>TSN.UA RSS feed</description>
<language>uk-ukr</language>
<pubDate>Fri, 04 Dec 2015 20:00:06 +0200</pubDate>
<ttl>300</ttl>
<image>
<url>http://tsn.ua/static/img/tsn_top_logo_rss.gif</url>
<title>Новини на tsn.ua - </title>
<link>http://tsn.ua/</link>
</image>
</channel>
</rss>
... etc
How I can get GENERAL pubDate of DOCUMENT using SimplePie?
Try the following, this parses the xml:
$xmlx='<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Новини на tsn.ua</title>
<link>http://tsn.ua/</link>
<description>TSN.UA RSS feed</description>
<language>uk-ukr</language>
<pubDate>Fri, 04 Dec 2015 20:00:06 +0200</pubDate>
<ttl>300</ttl>
<image>
<url>http://tsn.ua/static/img/tsn_top_logo_rss.gif</url>
<title>Новини на tsn.ua - </title>
<link>http://tsn.ua/</link>
</image>
</channel>
</rss>';
$xml = simplexml_load_string($xmlx);
if ($xml === false) {
echo "Failed loading XML: ";
foreach(libxml_get_errors() as $error) {
echo "<br>", $error->message;
}
} else {
var_dump($xml->channel->pubDate);
}
P.S: Next time please post the whole XML or a valid one
P.S 2: You can parse the date by using this function