Page 1 of 1

Help!!! How do you display timestamp in a readable format?

Posted: Sun Aug 05, 2007 5:58 pm
by jjohall2000
Hi,

I have the time and date stored in my mysql database as a timestamp. the problem is when you use echo to display it on the screen it displays the timestamp and not what the timestamp should be converted to. below is the method i am using to echo onto the screen;

Code: Select all

<td bgcolor="#FFFFFF"><? echo $rows['time_date']; ?></td>
How do i convert/format the timestamp to display the the atual date and time and not just the string of numbers timestamp uses?

Many Thanks

jjohall2000

Posted: Sun Aug 05, 2007 6:04 pm
by John Cartwright
You can format a timestamp using date()

Posted: Sun Aug 05, 2007 6:04 pm
by thiscatis
date("Y-m-d", $var_date)

Posted: Mon Aug 06, 2007 2:55 am
by timvw
I would do the conversion in the query instead of doing it aftwards in php...

http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html look at the functions FROM_UNIXTIME and DATE_FORMAT.