timezone_fromDateTimeZone_basic.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. IntlTimeZone::fromDateTimeZone(): basic test
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded('intl'))
  6. die('skip intl extension not enabled');
  7. --FILE--
  8. <?php
  9. ini_set("intl.error_level", E_WARNING);
  10. ini_set("intl.default_locale", "nl");
  11. date_default_timezone_set('Europe/Lisbon');
  12. $tz = IntlTimeZone::fromDateTimeZone(new DateTimeZone('Europe/Amsterdam'));
  13. var_dump($tz->getID(), $tz->getRawOffset());
  14. $dt = new DateTime('2012-01-01 00:00:00 CET');
  15. $dtz = $dt->getTimeZone();
  16. /* this is different from new DateTimeZone('CET'),
  17. * which gives a Europe/Berlin timezone */
  18. var_dump($dtz->getName());
  19. $tz = IntlTimeZone::fromDateTimeZone($dtz);
  20. var_dump($tz->getID(), $tz->getRawOffset());
  21. $dt = new DateTime('2012-01-01 00:00:00 +0340');
  22. $dtz = $dt->getTimeZone();
  23. /* I don't think this timezone can be generated without a DateTime object */
  24. var_dump($dtz->getName());
  25. $tz = IntlTimeZone::fromDateTimeZone($dtz);
  26. var_dump($tz->getID(), $tz->getRawOffset() /* (3*60+40)*60000 */);
  27. --EXPECTF--
  28. string(16) "Europe/Amsterdam"
  29. int(3600000)
  30. string(3) "CET"
  31. string(3) "CET"
  32. int(3600000)
  33. string(6) "+03:40"
  34. string(%d) "GMT+03%s0"
  35. int(13200000)