Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RSS feed not showing item time

Posted on 2011-03-20
3
Medium Priority
?
42 Views
Last Modified: 2016-05-10
The time displays on RSS feed items is not correct, it is not  the time when the item was created and saved in database. Can you please tell me that how I can correct it. Please see the code bellow. You can see the result here: http://khatesabz.info/rss.php

<?php
echo '<?xml version="1.0" ?>';
echo '<rss version="2.0">';
echo '<channel>';
echo '<title>RSS Feed</title>';
echo '<link>http://--.info</link>';
echo '<language>fa</language>';
echo '<description>" &#1582;&#1591; &#1587;&#1576;&#1586; "</description>';

require_once 'kamen/serverdata.php';
$conn = mysql_connect("$dbHost","$dbUser","$dbPass");
mysql_query('SET NAMES utf8');
$db = mysql_select_db("$dbName");
mysql_query("SET CHARACTER_SET_RESULTS=NULL");
$sql = "SELECT * FROM lastnews ORDER BY id DESC LIMIT 15";
$result = mysql_query($sql);
while($row=mysql_fetch_assoc($result)){
echo '<item>';
echo '<pubDate>'.$row['date'].'</pubDate>';
echo '<pubTime>'.$row['time'].'</pubTime>';
echo '<title>'.$row['title'].'</title>';
echo '<link>'.$row['code'].'</link>';
echo '<description>'.$row['description'].'</description>';
echo '</item>';
}
echo '</channel>';
echo '</rss>';
?>
0
Comment
Question by:sam20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 35177261
RSS is a specialized subset of XML.  You can find more information on RSS here.  A quick search of that page will show you that there is no "pubTime" tag defined.
http://cyber.law.harvard.edu/rss/rss.html

The correct format for the RSS pubDate is RFC822 or RFC 2822.  In PHP this is date('r') format.  I think your problem arises from providing the wrong format for pubDate.  Check these links.
http://asg.web.cmu.edu/rfc/rfc822.html
http://php.net/manual/en/function.date.php

I would also like to suggest that the use of MySQL reserved words like "date" and "time" for column names is a recipe for confusion.  Here is an article that shows a little more about how to handle date and time in PHP and MySQL.  See if it helps you sort out the information that you have to store in the data base and reproduce in the XML of the RSS feed.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

An object-oriented version of the article is available here.
https://www.experts-exchange.com/articles/20920/Handling-Time-and-Date-in-PHP-and-MySQL-OOP-Version.html

HTH, ~Ray
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question