0
我正在从MySQL数据库一个START_TIME字段值作为2012-08-14 21:30:00
,我想将其转换在PHP格式如2012-08-14T09:30是否有任何方法可以做
this in PHP的?
我正在从MySQL数据库一个START_TIME字段值作为2012-08-14 21:30:00
,我想将其转换在PHP格式如2012-08-14T09:30是否有任何方法可以做
this in PHP的?
$date = strtotime('2012-08-14 21:30:00');
echo date('Y-m-d\Th:i',$date);
看到这个example.for所需的日期&时间格式:
$date=date("Y-m-d H:i:s");//get the current date
$d=strtotime($date);//convert in strtotime
echo $final_date=date("Y-m-d\Th:i:s",$d);//in the first argument of date ,put the format whatever you want,but be sure to convert it in strtotime first.
但是,这将给以24小时格式 – 2012-08-18 08:19:31
都能跟得上...'h'时间是12小时格式,[参考](http://de.php.net/manual/en/function.date.php) – 2012-08-18 08:26:19
对不起,没有注意到。我正在寻找'a'(am/pm) – 2012-08-18 08:48:01