我编写了一个小脚本,直到上周工作正常......本周它突然停止了......我完全不知道问题是什么。
我知道代码很丑,但有人建议我应该从哪里开始寻找?
<?php
$hours = array('12:00','13:00','14:00','14:30','15:00','20:00','20:10','21:00');
//To the time Warp
$i = 1;
foreach ($hours as $est)
{
$time = $est;
putenv('TZ=US/Eastern');
//Set Timestamp for Time Zone conversions
$dateconv = date("Ymd g:i A", strtotime("$est"));
$timeconv = strtotime("$dateconv");
//Time Zone conversions //
$format = "g:i A - T (e)";
$gtp_time = '';
$gtp_time = $timeconv;
// America/Los Angeles
putenv('TZ=America/Los_Angeles');
$pst = date($format, $gtp_time);
// EST time:
putenv('TZ=America/New_York');
$est = date($format, $gtp_time);
// EST time:
putenv('TZ=America/Halifax');
$ast = date($format, $gtp_time);
// GMT time:
putenv('TZ=UTC');
$utc = date($format, $gtp_time);
// BST time:
putenv('TZ=Europe/London');
$bst = date($format, $gtp_time);
//CET
putenv('TZ=Europe/Amsterdam');
$cet = date($format, $gtp_time);
//Australia - Victoria
putenv('TZ=Australia/Victoria');
$aest = date($format, $gtp_time);
putenv('TZ=US/Eastern');
//${'time_'. $i}
$GLOBALS['time_'. $i] = "* " .$pst . "\r\n* " . $est . "\r\n* " . $ast . "\r\n* " . $utc . "\r\n* " . $bst . "\r\n* " . $cet . "\r\n* " . $aest;
$i++;
}
echo $time_1;
echo $time_2;
?>
现在脚本会返回:
- 12:00 PM - GMT(欧洲/伦敦)* 12:00 PM - GMT(欧洲/伦敦)* 12:00 PM - GMT(欧洲/伦敦)* 12:00 PM - GMT(欧洲/伦敦) * 中午12:00 - 格林威治标准时间(欧洲/伦敦)*中午12:00 - 格林尼治标准时间(欧洲/伦敦)* 中午12:00 - 格林尼治标准时间(欧洲/伦敦)
- 1:00 PM - GMT(欧洲/伦敦)* 1:00 PM - GMT(欧洲/伦敦)* 1:00 PM - GMT(欧洲/伦敦)* 1:00 PM - GMT(欧洲/伦敦) * 1:00 PM - GMT(欧洲/伦敦)*下午1:00 - 格林威治标准时间(欧洲/伦敦)*下午1:00 - 格林尼治标准时间 (欧/伦敦)
但它曾经为每个人返回适当的时间和区域......