Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

timestamp display on the page 1

Status
Not open for further replies.

Keendev

Technical User
Jan 23, 2006
106
PH
hi,

need a little help here in displaying record coming from database.

I have dateUpdated column field name (timestamp) on my table, and I output it on my php page using the date function.

Code:
 //put it in a var
$updated = $row[dateUpdated] ;
$updated = date("Y-m-d",$updated); 

// display
echo $updated ;

when i view it .. all of the date value displays "1970-01-01"

thanks in advance
 
AFAIK the timestamp (not unix timestamp) in a database is just a string and date() function needs an actual date to format it. You could run $updated through [tt]strtotime()[/tt], which would convert it to what you need.

However, if you're getting this date from mysql database, it is much quicker and better if you format it in the actual database, while you're retrieving it. You would then use DATE_FORMAT to format your timestamp appropriately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top