思路很簡單,首先呢,將原本的格式用字符串替換函數將T替換為空,然后把他轉化成時間戳這樣,想顯示什么樣的格式就用 date函數來輸出就可以了
//firstpowertime "2017-01-02T13:22:22" 獲取時間
$firstpowertime=$list[$i]['firstpowertime'];
//判斷是時間戳還是時間日期格式
$need=stripos($firstpowertime,"T");
if($need)
{
//截取字符串轉換
$shenme=str_replace('T',' ',$firstpowertime);
//如果是ISO8601格式,轉換為時間戳
$firstpowertime=strtotime($shenme);
//$firstpowertime=date('Y',$firstpowertime).'年'.date('n',$firstpowertime).'月'.date('j',$firstpowertime).'日'.date('H',$firstpowertime).'時'.date('i',$firstpowertime).'分'.date('s',$firstpowertime).'秒';
$firstpowertime=date("Y年n月j日 H:i:s",$firstpowertime);
}
$list[$i]['firstpowertime'] = $firstpowertime;