View Full Version : UNIX TIME problem

10-13-2009, 12:05 PM
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, 12:46 PM
What do you get for
echo $row['u__time']; ?

10-13-2009, 01:30 PM
And could you show how exactly you are inserting u__time to the DB table ? With NOW() ?

10-14-2009, 02:46 PM
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.