php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65554 createFromFormat broken when weekday name is followed by some delimiters
Submitted: 2013-08-25 22:01 UTC Modified: -
From: stas@php.net Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.4.19 OS: *
Private report: No CVE-ID:
 [2013-08-25 22:01 UTC] stas@php.net
Description:
------------
createFromFormat fails when in the format D or l is followed by separators that 
are not space or comma. 

Test script:
---------------
$string = "Thu., Nov. 29, 2012 5:00PM";

$data = DateTime::createFromFormat( "D., M# j, Y g:iA", $string );

var_dump( $data );
var_dump( DateTime::getLastErrors() );

Expected result:
----------------
object(DateTime)#1 (3) {
  ["date"]=>
  string(19) "2012-11-29 17:00:00"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(19) "America/Los_Angeles"
}
array(4) {
  ["warning_count"]=>
  int(0)
  ["warnings"]=>
  array(0) {
  }
  ["error_count"]=>
  int(0)
  ["errors"]=>
  array(0) {
  }
}


Actual result:
--------------
bool(false)
array(4) {
  ["warning_count"]=>
  int(0)
  ["warnings"]=>
  array(0) {
  }
  ["error_count"]=>
  int(2)
  ["errors"]=>
  array(2) {
    [0]=>
    string(32) "A textual day could not be found"
    [4]=>
    string(40) "The separation symbol could not be found"
  }
}


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-25 22:15 UTC] stas@php.net
Automatic comment on behalf of vlogvinskiy@cogniance.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e6424d89e9419e610ea95484081b9c26b0a7c044
Log: Fix bug #65554 in DateTime, when use it with D/l in format and textual day have dot at the end
 [2013-08-25 22:15 UTC] stas@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 19:01:51 2014 UTC