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]
problem with dates
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the "timestamp" used by the database does not correspond to the timestamp used by php. Try using DATE_FORMAT()
- chrys
- Forum Contributor
- Posts: 118
- Joined: Tue Oct 04, 2005 9:41 am
- Location: West Roxbury, MA (Boston)
Alternatively, you can try this:
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.
Code: Select all
date("M d Y H:i:s", strtotime($row['dateAdded']));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.
- chrys
- Forum Contributor
- Posts: 118
- Joined: Tue Oct 04, 2005 9:41 am
- Location: West Roxbury, MA (Boston)
I think it was December 31, 1969, the beginning of the epoch.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.)