获取即将到来的夏令时日期

g5w*_*5wx 4 php date dst

如何通过 PHP 获取特定时区即将到来的夏令时日期/时间更改?我想输出例如:

柏林即将于 2017 年 10 月 29 日凌晨 3 点更改时钟。

Yan*_*Man 5

$date = new DateTime();
$tz = $date->getTimezone();
$changes = $tz->getTransitions(strtotime("yesterday"), strtotime("+1 year"));
$n = count($changes);
$tnow = time();
for($i = 0; $i < $n; $i++)
{
    if($changes[$i]["ts"] > $tnow)
    {
        echo "Upcoming clock change for " . $tz->getName() . " will be on " . $changes[$i]["time"] . "\n";
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)