Skip to content

Commit 37d460b

Browse files
committedJul 21, 2022
Fixed #81263: Wrong result from DateTimeImmutable::diff
1 parent cc9c577 commit 37d460b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
 

‎ext/date/tests/bug81263.phpt

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
Bug #81263 (Wrong result from DateTimeImmutable::diff)
3+
--FILE--
4+
<?php
5+
6+
$dt1 = new DateTimeImmutable('2020-07-19 18:30:00', new DateTimeZone('Europe/Berlin'));
7+
$dt2 = new DateTimeImmutable('2020-07-19 16:30:00', new DateTimeZone('UTC'));
8+
9+
print_r($dt2->diff($dt1));
10+
print_r($dt1->diff($dt2));
11+
?>
12+
--EXPECTF--
13+
DateInterval Object
14+
(
15+
[y] => 0
16+
[m] => 0
17+
[d] => 0
18+
[h] => 0
19+
[i] => 0
20+
[s] => 0
21+
[f] => 0
22+
[weekday] => 0
23+
[weekday_behavior] => 0
24+
[first_last_day_of] => 0
25+
[invert] => 0
26+
[days] => 0
27+
[special_type] => 0
28+
[special_amount] => 0
29+
[have_weekday_relative] => 0
30+
[have_special_relative] => 0
31+
)
32+
DateInterval Object
33+
(
34+
[y] => 0
35+
[m] => 0
36+
[d] => 0
37+
[h] => 0
38+
[i] => 0
39+
[s] => 0
40+
[f] => 0
41+
[weekday] => 0
42+
[weekday_behavior] => 0
43+
[first_last_day_of] => 0
44+
[invert] => 1
45+
[days] => 0
46+
[special_type] => 0
47+
[special_amount] => 0
48+
[have_weekday_relative] => 0
49+
[have_special_relative] => 0
50+
)

0 commit comments

Comments
 (0)
Please sign in to comment.