我试图解析日期时间字符串组合日期和时间,想知道是否有一个更聪明的方式PHP解析日期时间字符串巧妙
样本数据
9/3/2013 8:50:05 AM
9/4/2013 1:42:28 PM
9/11/2013 12:01:21 PM
....
这里是我的“M doing..Looking直通日期时间字符串列表
<?php
$x = "9/3/2013 8:50:05 AM"
$ExDt = str_getcsv(trim($x," ");
$ExDate = $ExDt[0];
$ExTm = $ExDt[1] . " " . $ExDt[2];
$ExTime = date("H:i:s", strtotime($ExTm)); // Change to 24 hour format
echo $ExDate;
echo $ExTime;
?>
http://php.net/manual/en/datetime转换.createfromformat.php – zerkms
'strtotime(“2013/9/3 8:50:05 AM”)'不是简单的工作? –
那么你在这里改变的唯一的事情是把时间变成24小时? –