phpmysqldatetimenon-well-formed

how to display datetime type to this format: date("F j, Y, g:i a");?


I used datetime type in my table but I don't know how to display this using this format:

date("F j, Y, g:i a");

to have it look like: November 9, 2012, 9:17 am

I've tried

echo date("F j, Y, g:i a", $row["date"]); 

but I'm getting this error:

Notice: A non well formed numeric value encountered in C:\wamp\www\crud_exer\content.php on line 69

What should I do?


Solution

  • You should do this way:

    echo date("F j, Y, g:i a", strtotime($row["date"]));
    

    PHP: date - Manual