DateTimeImmutable_createFromInterface-001.phpt 1.7 KB

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