bug73426.phpt 774 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Bug #73426 (createFromFormat with 'z' format char results in incorrect time)
  3. --INI--
  4. date.timezone=UTC
  5. --FILE--
  6. <?php
  7. $date = '2016 12:00:00 15';
  8. $format = 'Y H:i:s z';
  9. var_dump(DateTime::createFromFormat($format, $date));
  10. $date = '16 12:00:00 2016';
  11. $format = 'z H:i:s Y';
  12. var_dump(DateTime::createFromFormat($format, $date));
  13. var_dump(DateTime::getLastErrors());
  14. ?>
  15. --EXPECTF--
  16. object(DateTime)#1 (3) {
  17. ["date"]=>
  18. string(26) "2016-01-16 12:00:00.000000"
  19. ["timezone_type"]=>
  20. int(3)
  21. ["timezone"]=>
  22. string(3) "UTC"
  23. }
  24. bool(false)
  25. array(4) {
  26. ["warning_count"]=>
  27. int(0)
  28. ["warnings"]=>
  29. array(0) {
  30. }
  31. ["error_count"]=>
  32. int(1)
  33. ["errors"]=>
  34. array(1) {
  35. [0]=>
  36. string(57) "A 'day of year' can only come after a year has been found"
  37. }
  38. }