calendar_fromDateTime_basic.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. IntlCalendar::fromDateTime(): 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_NL");
  11. date_default_timezone_set('Europe/Lisbon');
  12. $cal = IntlCalendar::fromDateTime('2012-01-01 00:00:00 Europe/Rome');
  13. var_dump(
  14. $cal->getTime(),
  15. strtotime('2012-01-01 00:00:00 Europe/Rome') * 1000.,
  16. $cal->getTimeZone()->getID(),
  17. $cal->getLocale(1)
  18. );
  19. echo "\n";
  20. $cal = IntlCalendar::fromDateTime(new DateTime('2012-01-01 00:00:00 PST'), "pt_PT");
  21. var_dump(
  22. $cal->getTime(),
  23. strtotime('2012-01-01 00:00:00 PST') * 1000.,
  24. $cal->getTimeZone()->getID(),
  25. $cal->getLocale(1)
  26. );
  27. echo "\n";
  28. $cal = intlcal_from_date_time(new DateTime('2012-01-01 00:00:00 +03:40'));
  29. var_dump(
  30. $cal->getTime(),
  31. strtotime('2012-01-01 00:00:00 +03:40') * 1000.,
  32. $cal->getTimeZone()->getID()
  33. );
  34. --EXPECTF--
  35. float(1325372400000)
  36. float(1325372400000)
  37. string(11) "Europe/Rome"
  38. string(5) "nl_NL"
  39. float(1325404800000)
  40. float(1325404800000)
  41. string(3) "PST"
  42. string(5) "pt_PT"
  43. float(1325362800000)
  44. float(1325362800000)
  45. string(%d) "GMT+03%S40"