dpbfb7119 2014-02-05 16:53
浏览 149
已采纳

如何转换要存储在mysql datetime中的日期和时间

How do I convert this to be stored in mysql database with a datetime field?

$phptime = '02/21/2014 9:30 am';
  • 写回答

5条回答 默认 最新

  • doushang1890 2014-02-05 16:57
    关注

    Convert the string to a timestamp, then use the php date function to get it in the format you want.

    $datetimeString = date( 'Y-m-d H:i:s', strtotime( $phptime ) );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)
编辑
预览

报告相同问题?