oo_001.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. date OO interface
  3. --FILE--
  4. <?php
  5. date_default_timezone_set('UTC');
  6. class _d extends DateTime {
  7. function __construct() {
  8. }
  9. }
  10. class _t extends DateTimeZone {
  11. function __construct() {
  12. }
  13. }
  14. $d = new DateTime;
  15. var_dump($d->format("Y-m-d H:i:s"));
  16. $d = new _d;
  17. var_dump($d->format("Y-m-d H:i:s"));
  18. try {
  19. new DateTime("1am todax");
  20. } catch (Exception $e) {
  21. echo $e->getMessage(),"\n";
  22. }
  23. $t = new DateTimeZone("UTC");
  24. var_dump($t->getName());
  25. $t = new _t;
  26. var_dump($t->getName());
  27. try {
  28. new DateTimeZone("GottaFindThisOne");
  29. } catch (Exception $e) {
  30. echo $e->getMessage(),"\n";
  31. }
  32. echo "DONE\n";
  33. ?>
  34. --EXPECTF--
  35. string(19) "%d-%d-%d %d:%d:%d"
  36. Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %soo_001.php on line %d
  37. bool(false)
  38. DateTime::__construct(): Failed to parse time string (1am todax) at position 4 (t): The timezone could not be found in the database
  39. string(3) "UTC"
  40. Warning: DateTimeZone::getName(): The DateTimeZone object has not been correctly initialized by its constructor in %soo_001.php on line %d
  41. bool(false)
  42. DateTimeZone::__construct(): Unknown or bad timezone (GottaFindThisOne)
  43. DONE