xref: /PHP-8.2/ext/date/tests/gh9891.phpt (revision d19a70c9)
1--TEST--
2Bug GH-9891 (DateTime modify with unixtimestamp (@) must work like setTimestamp)
3--FILE--
4<?php
5$m = new DateTime('2022-12-20 14:30:25', new DateTimeZone('Europe/Paris'));
6$m->modify('@1234567890');
7var_dump($m->getTimeStamp());
8
9echo "=======\n";
10
11$a = new DateTime('2022-11-01 13:30:00', new DateTimezone('America/Lima'));
12$b = clone $a;
13echo '$a: ', $a->format(DateTime::ATOM), "\n";
14echo '$b: ', $b->format(DateTime::ATOM), "\n";
15echo '$a: @', $a->getTimestamp(), "\n";
16echo '$b: setTimestamp(', $b->getTimestamp(), ")\n";
17$a->modify('@' . $a->getTimestamp());
18$b->setTimestamp($b->getTimestamp());
19echo '$a: ', $a->format(DateTime::ATOM), "\n";
20echo '$b: ', $b->format(DateTime::ATOM), "\n";
21?>
22--EXPECT--
23int(1234567890)
24=======
25$a: 2022-11-01T13:30:00-05:00
26$b: 2022-11-01T13:30:00-05:00
27$a: @1667327400
28$b: setTimestamp(1667327400)
29$a: 2022-11-01T18:30:00+00:00
30$b: 2022-11-01T13:30:00-05:00
31