xref: /php-src/ext/date/tests/bug52480.phpt (revision 091c0920)
1--TEST--
2Bug #52480 (Incorrect difference using DateInterval)
3--FILE--
4<?php
5
6$expectedDiff = (array) new DateInterval('P30D');
7
8// If the DateInterval object was created by DateTime::diff(), then this is the total
9// number of days between the start and end dates. Otherwise, days will be FALSE.
10// https://secure.php.net/manual/en/class.dateinterval.php
11$expectedDiff['days'] = 30;
12
13foreach (DateTimeZone::listIdentifiers() as $timezone) {
14    $start = new DateTime('2017-03-01', new DateTimeZone($timezone));
15    $end = new DateTime('2017-03-31', new DateTimeZone($timezone));
16
17    if ($expectedDiff != (array) $start->diff($end)) {
18        echo "\nWrong result for $timezone!\n";
19    }
20}
21?>
22===DONE===
23--EXPECT--
24===DONE===
25