Date formatting

Discussion in 'PHP' started by dhrystone, Oct 28, 2007.

  1. #1
    I have saved a timestamp in the database. I would like to retrieve it and print it as
    28 October 2007.
     
    dhrystone, Oct 28, 2007 IP
  2. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You could use the function DATE_FORMAT in mysql

    SELECT DATE_FORMAT(datefield, '%d %M %Y') FROM Tablename
     
    Kuldeep1952, Oct 28, 2007 IP
  3. theOtherOne

    theOtherOne Well-Known Member

    Messages:
    112
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Or, after fetching the timestamp into a variable such as $row['time']:
    date('d F Y', $row['time']);
    PHP:
     
    theOtherOne, Oct 28, 2007 IP