Log in

View Full Version : time stamp



nikomou
11-27-2008, 12:45 PM
hello,
i have a mySQL database with a timestamp to record when a user submits a comment.

$Date = $row[date];

How can I change this to "Thursday, 21st January 2008"

when used in this case:


echo ("$Date");


Thanks for your help!

BabblingIdjit
11-27-2008, 05:29 PM
$date_out = date('l jS F Y', $Date);

more info (http://www.php.net/manual/en/function.date.php)

nikomou
11-28-2008, 08:50 AM
Thanks, I thought that too, but it doesnt work! it keeps using the default date of:


Thursday 1st January 1970

I have no idea why!

Apache version 2.2.9 (Unix)
PHP version 5.2.6
MySQL version 4.1.22-standard

BabblingIdjit
11-28-2008, 08:54 AM
That's because $Date contains the value 0.

nikomou
11-28-2008, 09:45 AM
nope, because if I
echo ("$Date"); i get the value 2008-11-28 09:43:27

nikomou
11-28-2008, 09:47 AM
here's the full code:

$Date = $row[date];

$date_out = date('l jS F Y', $Date);

echo ("$date_out");
echo ("$Date");


Of which, the output is:

Thursday 1st January 1970
2008-11-28 09:43:27

thetestingsite
11-28-2008, 03:52 PM
Use strtotime() (http://us2.php.net/strtotime) to convert the date being returned from the sql query to a unix timestamp and then pass that value to the date function as mentioned before.

Hope this helps.

BabblingIdjit
11-28-2008, 05:11 PM
Well

Thursday 1st January 1970
2008-11-28 09:43:27

is NOT a timestamp.