我在MySQL中有一个日期时间列。

如何将其转换为显示为mm/dd/yy H:M (AM/PM)使用PHP?


当前回答

这会有用的……

echo date('m/d/y H:i (A)',strtotime($data_from_mysql));

其他回答

$date = "'".date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $_POST['date'])))."'";

直接输出,如德文格式:

  echo(date('d.m.Y H:i:s', strtotime($row["date_added"])));
$valid_date = date( 'm/d/y g:i A', strtotime($date));

参考:http://php.net/manual/en/function.date.php

这会有用的……

echo date('m/d/y H:i (A)',strtotime($data_from_mysql));

忘记所有。只使用:

$date = date("Y-m-d H:i:s",strtotime(str_replace('/','-',$date)))