xref: /PHP-8.2/ext/date/tests/bug73489.phpt (revision f0519f48)
1--TEST--
2Bug #73489: wrong timestamp when call setTimeZone multi times with UTC offset
3--FILE--
4<?php
5// example 1 - Timestamp is changing
6$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
7var_dump($datetime->getTimestamp());
8$datetime->setTimeZone(new DateTimeZone('-03:00'));
9$datetime->setTimeZone(new DateTimeZone('-03:00'));
10var_dump($datetime->getTimestamp());
11
12// example 2 - Timestamp keeps if you use getTimestamp() before second setTimeZone() calls
13$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
14var_dump($datetime->getTimestamp());
15$datetime->setTimeZone(new DateTimeZone('-03:00'));
16$datetime->getTimestamp();
17$datetime->setTimeZone(new DateTimeZone('-03:00'));
18var_dump($datetime->getTimestamp());
19?>
20--EXPECT--
21int(1478721600)
22int(1478721600)
23int(1478721600)
24int(1478721600)
25