SUPER EASY php mysql date display

how do you take a date variable from a mysql database and display it in the date format you choose?
ie.
$db_date=mysql_result($result,$i,"db_date");
$formated_date=$db_date(M,d,Y);
newbe101Asked:
Who is Participating?
 
hernst42Connect With a Mentor Commented:
use strtotime and date

$formated_date = date('M,d,Y', strtotime(mysql_result($result,$i,"db_date")));

See http://www.php.net/date and http://www.php.net/strtotime

how does the date from the db look?
0
 
Ali KayahanFull Stack DeveloperCommented:
$date = date("M,d,Y",$db_date) ;
0
 
Ali KayahanFull Stack DeveloperCommented:
It will work if you populate your field with time()
0
 
newbe101Author Commented:
Thank you again, hernst42 !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.