I have this date in mysql datetime field:
2011-12-10 18:27:51
I am using this code in php to display it:
$created_date = mysql_result($result, $i ,"created_date"); echo date("d/m/Y", $created_date);
$created_date = mysql_result($result, $i ,"created_date");
echo date("d/m/Y", $created_date);
but the result is wrong! here is the result:
31/12/1969
how can I fix it please?
Note that [man]date/man expects the optional second parameter to be in a specific format - a Unix timestamp.
However, note that MySQL can format the date in much the same capacity on its own; for example, see DATE_FORMAT() in the MySQL manual.
Try this:
$created_date = mysql_result($result, $i ,"created_date"); echo date("d/m/Y", strtotime($created_date));