在 Php7 的夏令时找到确切的午夜的解决方法

Workaround to find exact midnight within summertime in Php7

好的,这绝对是一个 PHP 7 错误。 我的问题是:您知道任何可靠的解决方法吗?

$date1 = new DateTime('2017-10-14', new DateTimeZone('America/Sao_Paulo'));
print_r($date1);
print_r('<br/>');
print_r('<br/>');
$date2 = new DateTime('2017-10-15', new DateTimeZone('America/Sao_Paulo'));
print_r($date2);
print_r('<br/>');
print_r('<br/>');
$date3 = new DateTime('2017-10-16', new DateTimeZone('America/Sao_Paulo'));
print_r($date3);

这会给我每天午夜,对吗?错误的。

DateTime Object ( [date] => 2017-10-14 00:00:00.000000 [timezone_type] => 3 [timezone] => America/Sao_Paulo ) 

DateTime Object ( [date] => 2017-10-15 01:00:00.000000 [timezone_type] => 3 [timezone] => America/Sao_Paulo ) 

DateTime Object ( [date] => 2017-10-16 00:00:00.000000 [timezone_type] => 3 [timezone] => America/Sao_Paulo )

15号凌晨一点。将偏移量设置为 -2 并增加一小时。它总是发生在 15 日。 php版本是7.0.22

我真的需要能够可靠地找到午夜! :)

It is one in the morning on the 15th... I really need to be able to reliably find midnight!

你不能。 2017 年 10 月 15 日圣保罗 没有当地午夜。它不存在。随着当地时间临近午夜,夏令时开始的 1:00 上午。以微秒计算,结果如下:

..
2017-10-14 23:59:59.999998 UTC-03:00 (BRT)
2017-10-14 23:59:59.999999 UTC-03:00 (BRT)
2017-10-15 01:00:00.000000 UTC-02:00 (BRST)
2017-10-15 01:00:00.000001 UTC-02:00 (BRST)
...

请参阅 this site 进行可视化。