Alex Rivera | Logout

Convert from MySQL datetime to another format with PHP

Asked 2008-09-25T23:10:30.203
481

I have a datetime column in MySQL.

How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?

Edit
Report

1 Answer

10

An easier way would be to format the date directly in the MySQL query, instead of PHP. See the MySQL manual entry for DATE_FORMAT.

If you'd rather do it in PHP, then you need the date function, but you'll have to convert your database value into a timestamp first.

answered 2008-09-25T23:15:23.950

Your Answer