SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Timestamp to readable date format

    Hi,

    How can I convert a timestamp into a date (25/08/2007)?

    I looked at php manual and I tried both date() and gmdate() but the date returned is wrong. For example, using my code below the timestamp 1188040652323 returns 19/01/2038 3.14:07 when it should return 25/08/2007.....:


    PHP Code:
    $time $_POST[enq_date]; 

    $date date("m/d/Y G.i:s"$time); 

    echo 
    $date
    FYI, I receive the timestamp value from an external server in a POST variable, I am trying to convert it into a normal date in order to insert it into one of my tables.

    Many thanks

  2. #2
    SitePoint Zealot Dachande663's Avatar
    Join Date
    Feb 2005
    Location
    Birmingham, UK
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That timestamp is in milliseconds, divide it by a thousand and then pass it to date() like so:
    PHP Code:
    $time $_POST[enq_date]/1000;
    $date date("m/d/Y G.i:s"$time);
    echo 
    $date
    Web Developer & Geek: hybridlogic.co.uk ~ lukelanchester.com


Bookmarks

Posting Permissions

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