请注意,DateTime参数对DateTimeZone::getOffset($DateTime)返回的结果没有影响,除非它指的是在引用的DateTimeZone中存在夏令时的DateTime。
例如。
<?php
$timezone_brl = new DateTimeZone('America/Sao_Paulo');
$timezone_eng = new DateTimeZone('Europe/London');
$timezone_aus = new DateTimeZone('Australia/Brisbane');
$dateTimes = [
new DateTime()
, new DateTime('now', $timezone_eng)
, new DateTime('now', $timezone_aus)
, new DateTime('now', $timezone_brl)
, new DateTime('2000-06-10', $timezone_brl)
, new DateTime('2000-12-10', $timezone_brl)
, new DateTime('2020-12-10', $timezone_brl)
];
foreach($dateTimes as $dateTime)
{
echo "\n" . $timezone_brl->getOffset($dateTime);
}
?>