View Full Version : UNIX TIME problem
10-13-2009, 11:05 AM
i am inserting data with unix time info but when i fetch it like following
echo date('d-m-Y | H:i:s',$row['u__time']);
it is output is 23-12-1973 | 08:49:25 why it is 1973. it must be 2009
10-13-2009, 11:46 AM
What do you get for
echo $row['u__time']; ?
10-13-2009, 12:30 PM
And could you show how exactly you are inserting u__time to the DB table ? With NOW() ?
Since "23-12-1973 08:49:25" equates to a unix time of 125484565, which if you add 1 becomes a date of 6th October 2009 04:14 PM (UTC), a couple days before his post, it would seem to me that he has set up his table with a length/limit of 9 on his timestamp field, which is 1 too short. If you store a too long value the MySQL versions I have worked with at least cut them off.
So Zodehala what you need to do is edit your MySQL table, and enter 10 into the Length/Values input box, then save. You old data will still have the old 9 length data until you fix that with the weapon of your choice (a short PHP script could handle it), but new data will be saved correctly.
Here's a good unix time site with which to figure out stuff like this by the way: unixtime.info (http://unixtime.info/). It's pretty liberal about accepting various date formats and such in the converter, and has a bunch of other features.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.