?yb? 2008-09-25 23:10 采纳率: 0%
浏览 529
已采纳

使用 PHP 将 MySQL 的日期时间转换为另一种格式

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?

转载于:https://stackoverflow.com/questions/136782/convert-from-mysql-datetime-to-another-format-with-php

  • 写回答

17条回答 默认 最新

  • ~Onlooker 2008-09-25 23:30
    关注

    To convert a date retrieved from MySQL into the format requested (mm/dd/yy H:M (AM/PM)):

    // $datetime is something like: 2014-01-31 13:05:59
    $time = strtotime($datetimeFromMysql);
    $myFormatForView = date("m/d/y g:i A", $time);
    // $myFormatForView is something like: 01/31/14 1:05 PM
    

    Refer to the PHP date formatting options to adjust the format.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(16条)

报告相同问题?