Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2007
    Posts
    269
    Thanks
    28
    Thanked 0 Times in 0 Posts

    UNIX TIME problem

    i am inserting data with unix time info but when i fetch it like following
    PHP Code:
    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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    What do you get for
    PHP Code:
    echo $row['u__time']; 
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    And could you show how exactly you are inserting u__time to the DB table ? With NOW() ?

  • #4
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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. It's pretty liberal about accepting various date formats and such in the converter, and has a bunch of other features.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •