bug45543.phpt 814 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Test for bug #45543: DateTime::setTimezone can not set timezones without ID.
  3. --INI--
  4. date.timezone=UTC
  5. --FILE--
  6. <?php
  7. $test_dates = array(
  8. '2008-01-01 12:00:00 PDT',
  9. '2008-01-01 12:00:00 +02:00',
  10. );
  11. foreach ($test_dates as $test_date)
  12. {
  13. $d1 = new DateTime($test_date);
  14. $d2 = new DateTime('2008-01-01 12:00:00 UTC');
  15. echo $d1->format(DATE_ISO8601), PHP_EOL;
  16. echo $d2->format(DATE_ISO8601), PHP_EOL;
  17. $tz = $d1->getTimeZone();
  18. $d2->setTimeZone($tz);
  19. echo $d1->format(DATE_ISO8601), PHP_EOL;
  20. echo $d2->format(DATE_ISO8601), PHP_EOL;
  21. echo PHP_EOL;
  22. }
  23. ?>
  24. --EXPECT--
  25. 2008-01-01T12:00:00-0700
  26. 2008-01-01T12:00:00+0000
  27. 2008-01-01T12:00:00-0700
  28. 2008-01-01T05:00:00-0700
  29. 2008-01-01T12:00:00+0200
  30. 2008-01-01T12:00:00+0000
  31. 2008-01-01T12:00:00+0200
  32. 2008-01-01T14:00:00+0200