DateTime_fix_createFromFormat.phpt 813 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. Test fix for DateTime when date have textual day with dot or other special char at end
  3. --FILE--
  4. <?php
  5. //Set the default time zone
  6. date_default_timezone_set('Europe/London');
  7. echo "*** Testing clone on DateTime objects ***\n";
  8. // Create a DateTime object..
  9. $orig = new DateTime('2012-11-29 17:00:00');
  10. // String to parse
  11. $string = "Thu., Nov. 29, 2012 5:00PM";
  12. // Create a DateTime object from format
  13. $fromFormat = DateTime::createFromFormat( "D., M# j, Y g:iA", $string );
  14. echo "Format method: " . $orig->format("D., M. j, Y g:iA") . "\n";
  15. echo "createFromFormat method: " . $fromFormat->format("D., M. j, Y g:iA") . "\n";
  16. ?>
  17. ===DONE===
  18. --EXPECTF--
  19. *** Testing clone on DateTime objects ***
  20. Format method: Thu., Nov. 29, 2012 5:00PM
  21. createFromFormat method: Thu., Nov. 29, 2012 5:00PM
  22. ===DONE===