Edit report at https://bugs.php.net/bug.php?id=53879&edit=1
ID: 53879 Comment by: bwhitehead at tableausoftware dot com Reported by: noels01 at gmx dot net Summary: DateTime::createFromFormat() fails to parse cookie expiration date Status: Open Type: Bug Package: Date/time related Operating System: Win 7 PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: Confirmed on MacOS 10.7.4 (PHP 5.3.10) According to this page: http://php.net/manual/en/class.datetime.php: const string COOKIE = "l, d-M-y H:i:s T" ; According to this page: http://php.net/manual/en/datetime.createfromformat.php Value should be:"D, d-M-Y H:i:s T" or "D, d-M-Y H:i:s e" The leading "Day of Week" (l) and "Year" (y) formats are incorrect. Confirmed parsing of standard cookie date with either of the above formats. Code: DateTime::createFromFormat("D, d-M-Y H:i:s T", "Mon, 29-Sep-2014 01:21:00 GMT"); DateTime::createFromFormat("D, d-M-Y H:i:s e", "Mon, 29-Sep-2014 01:21:00 GMT"); Result: object(DateTime)#1 (3) { ["date"]=> string(19) "2014-09-29 01:21:00" ["timezone_type"]=> int(2) ["timezone"]=> string(3) "GMT" } array(4) { ["warning_count"]=> int(0) ["warnings"]=> array(0) { } ["error_count"]=> int(0) ["errors"]=> array(0) { } } Previous Comments: ------------------------------------------------------------------------ [2011-01-29 16:43:13] noels01 at gmx dot net Description: ------------ The class DateTime is supposed to handle date strings like used for cookie expiration dates. It explicitly defines the format DateTime::COOKIE but fails to parse it. Test script: --------------- <?php $date = DateTime::createFromFormat(DateTime::COOKIE, "Mon, 21-Jan-2041 15:24:52 GMT"); print_r($date); ?> Same goes for <?php $date = date_parse_from_format(DateTime::COOKIE, "Mon, 21-Jan-2041 15:24:52 GMT"); print_r($date); ?> Expected result: ---------------- Something with a date instead of NULL O.o Actual result: -------------- Array ( [year] => 2020 [month] => 1 [day] => 21 [hour] => 41 [minute] => 15 [second] => 24 [fraction] => [warning_count] => 1 [warnings] => Array ( [25] => The parsed time was invalid ) [error_count] => 4 [errors] => Array ( [16] => Unexpected data found. [22] => The timezone could not be found in the database [25] => Trailing data ) [is_localtime] => 1 [zone_type] => 0 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=53879&edit=1