xref: /PHP-8.3/ext/date/tests/bug80664.phpt (revision 091c0920)
1--TEST--
2Bug #80664 (DateTime objects behave incorrectly around DST transition)
3--FILE--
4<?php
5$dt = new DateTime('@1604215800');
6$dt->setTimezone(new DateTimeZone('America/Boise'));
7echo "{$dt->format('Y-m-d H:i:s T')} | {$dt->getTimestamp()}\n";
8$dt->add(new DateInterval('PT1H'));
9echo "{$dt->format('Y-m-d H:i:s T')} | {$dt->getTimestamp()}\n";
10$dt->add(new DateInterval('PT1H'));
11echo "{$dt->format('Y-m-d H:i:s T')} | {$dt->getTimestamp()}\n";
12$dt->add(new DateInterval('PT1M'));
13echo "{$dt->format('Y-m-d H:i:s T')} | {$dt->getTimestamp()}\n\n";
14
15$dt = new DateTime('@1604219400');
16$dt->setTimezone(new DateTimeZone('UTC'));
17echo "{$dt->format('Y-m-d H:i:s T')} | {$dt->getTimestamp()}\r\n";
18$dt->setTimezone(new DateTimeZone('America/Boise'));
19echo "{$dt->format('Y-m-d H:i:s T')} | {$dt->getTimestamp()}\r\n";
20?>
21--EXPECT--
222020-11-01 01:30:00 MDT | 1604215800
232020-11-01 01:30:00 MST | 1604219400
242020-11-01 02:30:00 MST | 1604223000
252020-11-01 02:31:00 MST | 1604223060
26
272020-11-01 08:30:00 UTC | 1604219400
282020-11-01 01:30:00 MST | 1604219400
29