bug52480.phpt 728 B

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