0
我想爲不同的棒球隊輸入比賽時間。我想要使用下面的foreach
循環。 PHP會將所有循環的時區設置爲America/New_York
。如何在foreach循環中設置不同的時區?
$BaseballTeams = array('America/New_York' => 'Maryville College', 'America/Chicago' => 'LeMoyne-Owen College', 'America/Denver' => 'Utah State', 'Pacific/Honolulu' => 'Hawaii Tech');
foreach ($BaseballTeams as $Key => $Value){
date_default_timezone_set($Key); //Set the time zone for this team.
//Make a time stamp for that time zone
$TimeStamp = mktime($Hour,$Minute,$Second,$Month,$Day,$Year);
//Make a time stamp for that time zone
$MySQLi -> query("UPDATE Games SET GameDate = $TimeStamp WHERE TeamName = $Value");
}
而............ – AbraCadaver
夏威夷科技的時間戳記輸入紐約時間。我嘗試使用偏移功能,但我無法讓它們正常工作。 $ Offset = new DateTime('2015-5-21',new DateTimeZone($ HomeTeamTimeZone)); echo $ Offset-> getOffset(); – Harvey
此外,它看起來像你每次通過循環更新相同的記錄。 – AbraCadaver