SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Readable date!

  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Readable date!

    Does anyone have a pre-made function to convert a unix timestamp to something that a human can read? I am just looking for something that will change:
    20010609000700

    to:

    6/10/2001 12:07:00 AM

    or anything similar that can be read by a human.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I don't but php and mysql do. Check out the date() function at www.php.net. mysql can also format dates for you when you query a database for a timestamp. See "date and time functions" at www.mysql.com.

  3. #3
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    date("m/d/y h:i:s",$timestamp);
    or
    date("m/d/y h:i:s",20010609000700);

    will both produce a readable date, assuming $timestamp has a valid UNIX timestamp as it's value.

    ( m = 2digit month, d = 2digit day, y = 2digit year, h = hour, i = minutes, s = seconds. the rest of the possibilites can be found at www.php.net/date )
    Kevin

  4. #4
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but how do I capture that as a value? or do I just stick it where I want it echoed

  5. #5
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    he he, I just put it where I wanted, thanks! it worked perfectly


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
  •