Convert from MySQL datetime to another format with PHP

后端 未结 18 1486
醉话见心
醉话见心 2020-11-22 01:08

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?

18条回答
  •  温柔的废话
    2020-11-22 01:27

    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.

提交回复
热议问题