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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jjohall2000
Forum Newbie
Posts: 1
Joined: Sun Aug 05, 2007 5:44 pm

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

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You can format a timestamp using date()
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

date("Y-m-d", $var_date)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.
Post Reply