我试图在我的网站上展示几个世界时间。我正在寻找更新时间/保持准确的最精确方法,同时结合 BST 1 小时飞跃。
到目前为止我有
<?php
date_default_timezone_set('Europe/London');
$uk_time = date("g:i A");
$month = date("n");
if ($month < 3 || $month > 10) //January, February, November and December are not BST months.
{
$us_time = date("g:i A", strtotime('-4 hours'));
$dub_time = date("g:i A", strtotime('+4 hours'));
$kong_time = date("g:i A", strtotime('+8 hours'));
}
elseif ($month > 3 || $month < 10) //April to September are BST months.
{
$us_time = date("g:i A", strtotime('-5 hours'));
$dub_time = date("g:i A", strtotime('+3 hours'));
$kong_time = date("g:i A", strtotime('+7 hours'));
}
?>
<div class="time-left">
<ul>
<li class="clock"><strong>New York:</strong> <?php echo "$us_time" ?></li>
<li><strong>London:</strong> <?php echo "$uk_time" ?></li>
<li><strong>Dubai:</strong> <?php echo "$dub_time" ?></li>
<li><strong>Hong Kong:</strong> <?php echo "$kong_time" ?></li>
</ul>
</div>
我想知道是否有更好的方法
干杯
杰夫