xref: /PHP-8.3/ext/date/tests/bug52290.phpt (revision d679f022)
1--TEST--
2Bug #52290 (setDate, setISODate, setTime works wrong when DateTime created from timestamp)
3--FILE--
4<?php
5$tz = 'UTC';
6date_default_timezone_set($tz);
7
8$ts = strtotime('2006-01-01');
9$dt = new DateTime('@'.$ts);
10$dt->setTimezone(new DateTimeZone($tz));
11
12var_dump($dt->format('o-\WW-N | Y-m-d | H:i:s | U'));
13
14$dt->setISODate(2005, 52, 1);
15var_dump($dt->format('o-\WW-N | Y-m-d | H:i:s | U'));
16
17$dt->setDate(2007, 10, 10);
18var_dump($dt->format('o-\WW-N | Y-m-d | H:i:s | U'));
19
20$dt->setTime(20, 30, 40);
21var_dump($dt->format('o-\WW-N | Y-m-d | H:i:s | U'));
22?>
23--EXPECT--
24string(47) "2005-W52-7 | 2006-01-01 | 00:00:00 | 1136073600"
25string(47) "2005-W52-1 | 2005-12-26 | 00:00:00 | 1135555200"
26string(47) "2007-W41-3 | 2007-10-10 | 00:00:00 | 1191974400"
27string(47) "2007-W41-3 | 2007-10-10 | 20:30:40 | 1192048240"
28