File tree Expand file tree Collapse file tree 5 files changed +76
-0
lines changed Expand file tree Collapse file tree 5 files changed +76
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ PHP NEWS
1010 . Fixed bug GH-9650 (Can't initialize heap: [0x000001e7]). (Michael Voříšek)
1111 . Fixed potentially undefined behavior in Windows ftok(3) emulation. (cmb)
1212
13+ - Date:
14+ . Fixed bug GH-9699 (DateTimeImmutable::diff differences in 8.1.10 onwards -
15+ timezone related). (Derick)
16+ . Fixed bug GH-9700 (DateTime::createFromFormat: Parsing TZID string is too
17+ greedy). (Derick)
18+ . Fixed bug GH-9866 (Time zone bug with \DateTimeInterface::diff()). (Derick)
19+ . Fixed bug GH-9880 (DateTime diff returns wrong sign on day count when using
20+ a timezone). (Derick)
21+
1322- FPM:
1423 . Fixed bug GH-9959 (Solaris port event mechanism is still broken after bug
1524 #66694). (Petr Sumbera)
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug GH-9699 (DateTimeImmutable::diff differences in 8.1.10 onwards - timezone related)
3+ --FILE--
4+ <?php
5+
6+ $ date = new DateTimeImmutable ('2022-10-09 02:41:54.515330 ' , new DateTimeZone ('America/Los_Angeles ' ));
7+ $ now = new DateTimeImmutable ('2022-10-10 08:41:54.534620 ' , new DateTimeZone ('UTC ' ));
8+
9+ echo $ date ->diff ($ now )->format ("%R %Y %M %D %H %I %S %F " ), "\n" ;
10+ ?>
11+ --EXPECT--
12+ + 00 00 00 23 00 00 019290
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug GH-9700 (DateTime::createFromFormat: Parsing TZID string is too greedy)
3+ --FILE--
4+ <?php
5+ var_dump (DateTime::createFromFormat ('Y-m-d\TH:i:sP[e] ' , '2022-02-18T00:00:00+01:00[Europe/Berlin] ' ));
6+ ?>
7+ --EXPECTF--
8+ object(DateTime)#%d (%d) {
9+ ["date"]=>
10+ string(26) "2022-02-18 00:00:00.000000"
11+ ["timezone_type"]=>
12+ int(3)
13+ ["timezone"]=>
14+ string(13) "Europe/Berlin"
15+ }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug GH-9866 (Time zone bug with \DateTimeInterface::diff())
3+ --FILE--
4+ <?php
5+ function getYearsBetween (
6+ \DateTimeImmutable $ startDate ,
7+ \DateTimeImmutable $ endDate ,
8+ ): int {
9+ $ dateInterval = $ startDate ->diff ($ endDate , true );
10+ return $ dateInterval ->y ;
11+ }
12+
13+ $ start = new \DateTimeImmutable ('2000-11-01 09:29:22.907606 ' , new \DateTimeZone ('America/Chicago ' ));
14+ $ end = new \DateTimeImmutable ('2022-06-06 11:00:00.000000 ' , new \DateTimeZone ('America/New_York ' ));
15+ $ result = getYearsBetween ($ start , $ end );
16+ var_dump ($ result );
17+ $ diff = $ start ->diff ($ end );
18+ echo $ diff ->format ("%R %Y %M %D (%a) %H %I %S %F " ), "\n" ;
19+ ?>
20+ --EXPECT--
21+ int(21)
22+ + 21 07 04 (7886) 23 30 37 092394
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug GH-9880 (DateTime diff returns wrong sign on day count when using a timezone)
3+ --FILE--
4+ <?php
5+
6+ ini_set ('date.timezone ' , 'America/Los_Angeles ' );
7+
8+ $ nowTime = new DateTime ();
9+ $ nowTime ->setTimestamp (1667416695 );
10+
11+ $ dateTime = new DateTime ();
12+ $ dateTime ->setTimestamp (1671904800 );
13+ $ dateTime ->setTimezone (new DateTimeZone ('America/New_York ' ));
14+
15+ echo $ dateTime ->diff ($ nowTime )->format ('%R %a %H %I %S ' ), "\n" ;
16+ ?>
17+ --EXPECT--
18+ - 51 22 41 45
You can’t perform that action at this time.
0 commit comments