bug42910.phpt 1.2 KB

123456789101112131415161718192021222324252627282930
  1. --TEST--
  2. Bug #42910 (Constructing DateTime with TimeZone Indicator invalidates DateTimeZone)
  3. --FILE--
  4. <?php
  5. date_default_timezone_set('America/Los_Angeles');
  6. $foo = new DateTime('2007-03-11');
  7. $bar = new DateTime('2007-03-11T00:00:00-0800');
  8. print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
  9. print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
  10. $foo->setDate(2007, 03, 12);
  11. $bar->setDate(2007, 03, 12);
  12. print $foo->format(DateTime::ISO8601) . ' - ' . $foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
  13. print $bar->format(DateTime::ISO8601) . ' - ' . $bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
  14. // --------------
  15. date_default_timezone_set('Australia/Sydney');
  16. $date= date_create('2007-11-04 12:00:00+0200');
  17. var_dump(date_format($date, 'O e'));
  18. ?>
  19. --EXPECT--
  20. 2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
  21. 2007-03-11T00:00:00-0800 - -08:00 - 1173600000
  22. 2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
  23. 2007-03-12T00:00:00-0800 - -08:00 - 1173686400
  24. string(12) "+0200 +02:00"