php 例子 如何轉換ISO8601為 utc時間


思路很簡單,首先呢,將原本的格式用字符串替換函數將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;
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM