How can one efficiently retrieve and display the timestamp of news articles in an RSS feed using PHP?

To efficiently retrieve and display the timestamp of news articles in an RSS feed using PHP, you can parse the XML data from the feed and extract the timestamp information from the <pubDate> element. You can then format the timestamp as needed and display it alongside the article title.

&lt;?php
$rss = simplexml_load_file(&#039;https://example.com/news-feed.xml&#039;);

foreach ($rss-&gt;channel-&gt;item as $item) {
    $title = $item-&gt;title;
    $timestamp = date(&#039;Y-m-d H:i:s&#039;, strtotime($item-&gt;pubDate));
    
    echo &quot;&lt;p&gt;$title - $timestamp&lt;/p&gt;&quot;;
}
?&gt;