我想在 php 中转换 12 小时时间,格式如下:05/31/2012 09:48 AM
到 24 小时时间格式:2011-11-27 11:53:36
这是我可以更改的代码行:
$time= $_POST['时间'];
我想在 php 中转换 12 小时时间,格式如下:05/31/2012 09:48 AM
到 24 小时时间格式:2011-11-27 11:53:36
这是我可以更改的代码行:
$time= $_POST['时间'];
您可以使用strtotime
thendate
函数。
http://php.net/manual/en/function.date.php那里列出了所有可能的选项。
date 的第一个参数是格式,第二个参数是时间戳(通过 strtotime 获得的当前日期字符串)。
date('Y-m-d H:i:s', strtotime($your_current_date_string));
格式就在我的脑海中,并不准确。您可以在提供的链接中的表格中查找您需要的格式。
你必须像这样使用 strtotime :
$date="05/31/2012 09:48 AM";
echo date("Y-m-d H:i:s",strtotime($date));
通过以下链接了解 PHP 中的日期功能