DateTime_createFromInterface-002.phpt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. --TEST--
  2. Tests for DateTime::createFromInterface with inheritance
  3. --INI--
  4. date.timezone=Europe/London
  5. --FILE--
  6. <?php
  7. class MyDateTime extends DateTime {}
  8. $current = "2014-03-02 16:24:08";
  9. $i = MyDateTime::createFromInterface( date_create( $current ) );
  10. var_dump( $i );
  11. $i = MyDateTime::createFromInterface( date_create_immutable( $current ) );
  12. var_dump( $i );
  13. $current = "2019-12-16 15:06:46 CET";
  14. $i = MyDateTime::createFromInterface( date_create( $current ) );
  15. var_dump( $i );
  16. $i = MyDateTime::createFromInterface( date_create_immutable( $current ) );
  17. var_dump( $i );
  18. $current = "2019-12-16 15:08:20 +0100";
  19. $i = MyDateTime::createFromInterface( date_create( $current ) );
  20. var_dump( $i );
  21. $i = MyDateTime::createFromInterface( date_create_immutable( $current ) );
  22. var_dump( $i );
  23. ?>
  24. --EXPECTF--
  25. object(MyDateTime)#%d (3) {
  26. ["date"]=>
  27. string(26) "2014-03-02 16:24:08.000000"
  28. ["timezone_type"]=>
  29. int(3)
  30. ["timezone"]=>
  31. string(13) "Europe/London"
  32. }
  33. object(MyDateTime)#%d (3) {
  34. ["date"]=>
  35. string(26) "2014-03-02 16:24:08.000000"
  36. ["timezone_type"]=>
  37. int(3)
  38. ["timezone"]=>
  39. string(13) "Europe/London"
  40. }
  41. object(MyDateTime)#%d (3) {
  42. ["date"]=>
  43. string(26) "2019-12-16 15:06:46.000000"
  44. ["timezone_type"]=>
  45. int(2)
  46. ["timezone"]=>
  47. string(3) "CET"
  48. }
  49. object(MyDateTime)#%d (3) {
  50. ["date"]=>
  51. string(26) "2019-12-16 15:06:46.000000"
  52. ["timezone_type"]=>
  53. int(2)
  54. ["timezone"]=>
  55. string(3) "CET"
  56. }
  57. object(MyDateTime)#%d (3) {
  58. ["date"]=>
  59. string(26) "2019-12-16 15:08:20.000000"
  60. ["timezone_type"]=>
  61. int(1)
  62. ["timezone"]=>
  63. string(6) "+01:00"
  64. }
  65. object(MyDateTime)#%d (3) {
  66. ["date"]=>
  67. string(26) "2019-12-16 15:08:20.000000"
  68. ["timezone_type"]=>
  69. int(1)
  70. ["timezone"]=>
  71. string(6) "+01:00"
  72. }