How to format mysql date in php?

We always face problem while saving and displaying the date field, so must need to know how to format the date while displaying the date to the user.

To resolve the issue of displaying the date in dd-mm-yyyy format when it is saved in the mysql database as yyyy-mm-dd do the following:

$resdate=mysql_query(“select DATE_FORMAT(date_column_name, ‘%d/%m/%y’) AS formated_created_date from user where userid=’$userid’”);

echo $rowd[“formated_created_date”];


Leave a Reply