我要转换:
2010-12-24 11:39:43
为:
24/12 11:39
感谢。
答案 0 :(得分:5)
这应该是诀窍:
$newFormat = Date ( 'd/m H:i', StrToTime ( '2010-12-24 11:39:43' ) );
使用StrToTime将日期的字符串表示形式转换为时间戳。然后,将该时间戳提供给Date函数,该函数将日期格式作为第一个参数。
答案 1 :(得分:4)
尝试:
$unixtime = strtotime("2010-12-24 11:39:43");
$newFormat = date("d/m H:i", $unixtime);
答案 2 :(得分:3)
echo date("d/m H:i", strtotime("2010-12-24 11:39:43"));
答案 3 :(得分:1)
$date = DateTime::createFromFormat('Y-m-d G:i:s', 2010-12-24 11:39:43); //You can simply tell DateTime accept your timestamp as is since PHP 5.3
echo $date->format('d/m G:i T'); //Will output what you wanted + Timezone Abbreviation (because of the T)