Jump to content

RSS feed - correct time?


ruddie

Recommended Posts

Hello, I got myself a RSS feed for my posts, which can be seen here:

codexplained.tk/feed/rss.php

 

This is the code used for it:

<?php	
// header
header("Content-Type: application/xml; charset=UTF-8");
require("../widgets/functions.php");

// Make a MySQL Connection
connectToDB();	

echo '
	<rss version="2.0">
	<channel>
	<title>Codexplained RSS Feed</title>
	<link>http://www.codexplained.tk</link>
	<description>For all your coding needs</description>
	<language>en</language>
';

$query = "SELECT * FROM posts ORDER BY Id DESC LIMIT 15";
$res = mysql_query($query);

$num=mysql_numrows($res);	

$i = 0;	
while ($i < $num)
{	
	$subject=mysql_result($res,$i,"Subject");
	$id=mysql_result($res,$i,"Id");
	$content=mysql_result($res,$i,"Content");	

	$content = str_replace("<br />", "\n", $content);
	$content = str_replace("<?php", "<?php", $content);	
	$content = str_replace("?>", "?>", $content);		
	$content = htmlentities($content);	
	$content = substr($content, 0,400);		

	echo '
		<item>
		<title>'.$subject.'</title>
		<link>http://www.codexplained.tk/index.php?postDetails='.$id.'</link>			
		<description>'.$content.'</description>
		</item>';	
	$i++;
}
echo '
	</channel>
	</rss>
	';
?>

 

Now, I wish to know how to make the time display correctly, and not just according to refresh date.

 

I tried something with <pubDate> but I couldn't figure it out. Help would be appreciated!

 

Link to comment
https://forums.phpfreaks.com/topic/230421-rss-feed-correct-time/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.