Forum Moderators: coopster

Message Too Old, No Replies

Problem with date() and timestamp

         

barns101

3:40 pm on May 11, 2007 (gmt 0)

10+ Year Member



I've used date() a million time before with a Unix timestamp pulled out of a MySQL database but this time it just isn't working as expected:


<?php
mysql_connect('localhost', 'x', 'x');
mysql_select_db('x');
$query = mysql_query('SELECT * FROM `pub_news` ORDER BY `date` DESC');
while ($row = mysql_fetch_array($query))
{
echo date("nS F Y", $row[date])."<br>";
}
?>

The two database values for the 'date' field are '1178364600' (5th May 2007) and '1178896085' (11th May 2007). The code outputs the correct values for the fields as $row[date], but date() displays both as 5th May 2007.

I have checked the server time and although it's a few minutes fast, it seems OK. Am I being really stupid and missing something obvious?

Little_G

4:00 pm on May 11, 2007 (gmt 0)

10+ Year Member



Hi,

The

n
code represents the numeric representation of the month, you want
j
.

Andrew

barns101

12:58 pm on May 12, 2007 (gmt 0)

10+ Year Member



Spot the deliberate mistake! ;) Don't I feel like an idiot!

Thanks.