[RESOLVED] working with dates
Hi
I'm pretty new to php & mysql and am looking help with a problem I have with dates. Here is some code I am using:
Code:
$result = mysql_query("
SELECT date_format(`ItemPubDate_t`,'%H:%i %d %b %y'), ItemTitle,ItemLink,ItemSourceURL
FROM feedItems WHERE `ItemPubDate_t` >=
DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 60 MINUTE)
ORDER BY `ItemPubDate_t` DESC LIMIT 30", $connection);
if(!$result) {
die("Database selection failed: " . mysql_error());
}
If ($row = $result){
echo "New feeds added within last 1 hour<br/ >";
while ($row = mysql_fetch_array($result)){
echo "<tr><td>$row[0] <A href=$row[2]>$row[1]</A></td></tr>";
}
}
I have a table in the mysql database that has a list of rss feeds that updates frequently. I am trying to display on my webpage feeds added within the last 1 hour. The problem is, when I use the above code, it displays feeds added within the past 2 hours. From some brief research, it would appear (now please correct me if I am wrong) my server time is in UTC which is 1 hour behind BST which I want which is the problem.
Can anyone help me sort this problem?
Thanks
Damian
[RESOLVED] Re: working with dates
Quote:
Originally Posted by
kows
couldn't you just get rid of the DATE_SUB call and use the current timestamp?
Thanks, I see what u mean
Quote:
Originally Posted by
kows
oh, and I was just wondering; why do you have an IF statement defining $row as $result?
Have just been learning both php & mysql and thoughy I'd copied exactly what was on a tutorial from lynda.com, but having checked it, I see I copied it in error.
Thanks alot for your help, it is greatly appreciated.