2016-09-29 70 views
0

這是時區轉換的功能,如果在某個循環中 - 錯誤:無法重新聲明NEWtimezone()(先前聲明...不能重新聲明NEWtimezone()(先前聲明

function NEWtimezone($time,$defaultzone,$newzone) 
    { 
    $date = new DateTime($time, new DateTimeZone($defaultzone)); 
    $date->setTimezone(new DateTimeZone($newzone)); 
    $result=$date->format('Y-m-d H:i:s.u'); 
    return $result; 
    } 

$newzone="Europe/Moscow"; 
$defaultzone = "+1000"; 
$time = "2016-09-29 07:27:00.966"; 

回答

0

Can not redeclare function NEWtimezone() ....錯誤意味着功能NEWtimezone()已定義的,但你的代碼試圖再次定義它。

確保函數定義置於外循環。