SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Funky date

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

    Funky date

    I am using the PHP date function like this:

    PHP Code:
    date("m/d/y",$row["date"]) 
    but I am getting a very odd date..saying 08/20/70...here is the time stamp that it is using.

    Code:
    20010522
    and in the database (MySQL) it is timestamp(8)
    I am trying to get that to a readable date like this:

    05/22/2001

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll need to use MySQL functions instead of PHP functions. date() takes a unix timestamp which is usually a number like 992670321 which is the number of seconds since the unix epoch or Jan 1, 1970.


    You want to do this

    PHP Code:
    $result mysql_query("SELECT DATE_FORMAT(date, '%m/%d/%Y') as date from tablename"); 
    now $row["date"] will have it in the format you want



    Check out http://mysql.he.net/documentation/my...time_functions for more information
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •