Page 1 of 1
problem with dates
Posted: Tue Oct 04, 2005 11:14 am
by UndpUndo
this will hopefully be quite simple for someone however its giving me plenty of problems.
I have a timestamp(14) msql field that is being return from a query. The data in the field is 20051004165312.
I am using php'sd date("M d Y H:i:s", $row['dateAdded']) on the data return but it is producing a date: Jan 19 2038 03:14:07 which is way off. it should be something like OCt 04 2005 etc.
what am i doing wrong??[/i]
Posted: Tue Oct 04, 2005 11:19 am
by feyd
the "timestamp" used by the database does not correspond to the timestamp used by php. Try using
DATE_FORMAT()
Posted: Tue Oct 04, 2005 11:21 am
by chrys
Alternatively, you can try this:
Code: Select all
date("M d Y H:i:s", strtotime($row['dateAdded']));
strtotime() is a beautiful function. Read up on it
Note: It might not work with the timestamp you got, but it's worth a shot. If not, look into DATE_FORMAT() which is MySQL's function to format a date.
Posted: Tue Oct 04, 2005 11:29 am
by UndpUndo
thanks for your help chaps
appreciated

Posted: Tue Oct 04, 2005 1:20 pm
by pilau
As you can see with a little close-up on the "timestamp" you have on your DB: 20051004165312
2005/10/04 - 16:53:12; a date format.
Where a "real" UNIX timestamp would be the number of seconds passed since January 1st 1970. (or "71, cant remember exactly.)
Posted: Tue Oct 04, 2005 1:22 pm
by chrys
pilau wrote:As you can see with a little close-up on the "timestamp" you have on your DB: 20051004165312
2005/10/04 - 16:53:12; a date format.
Where a "real" UNIX timestamp would be the number of seconds passed since January 1st 1970. (or "71, cant remember exactly.)
I think it was December 31, 1969, the beginning of the epoch.