Convert from MySQL datetime to another format with PHP

后端 未结 18 1213
醉话见心
醉话见心 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

    Using PHP version 4.4.9 & MySQL 5.0, this worked for me:

    $oDate = strtotime($row['PubDate']);
    $sDate = date("m/d/y",$oDate);
    echo $sDate
    

    PubDate is the column in MySQL.

提交回复
热议问题