Use of date function in PHP to output a user-friendly date

Posted by Jamie on Stack Overflow See other posts from Stack Overflow or by Jamie
Published on 2011-02-09T23:17:27Z Indexed on 2011/02/09 23:26 UTC
Read the original article Hit count: 228

Filed under:
|
|

I have a MySQL database column named DateAdded.
I'd like to echo this as a readable date/time.
Here is a simplified version of the code I currently have:

$result = mysql_query("
    SELECT ListItem, DateAdded
    FROM lists
    WHERE UserID = '" . $currentid . "' 
    ");
while($row = mysql_fetch_array($result))
    {
    // Make the date look nicer
    $dateadded = date('d-m-Y',$row['DateAdded']);

    echo $row['ListItem'] . ",";
    echo $dateadded;
    echo "<br />";
    }

Is the use of the date function the best way to output a user-friendly date?

Thanks for taking a look,

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql