Bug #69408 [Opn->Nab]: Date strings consisting of year > 1999 not properly parsed
| From: | requinix@php.net | Date: | Thu, 09 Apr 2015 18:06:42 +0000 |
| Subject: | Bug #69408 [Opn->Nab]: Date strings consisting of year > 1999 not properly parsed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191921@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69408&edit=1
ID: 69408
Updated by: requinix@php.net
Reported by: jkronika at gridlined dot com
Summary: Date strings consisting of year > 1999 not properly
parsed
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: 5.5.23
Block user comment: N
Private report: N
New Comment:
date_parse() follows the rules for strtotime(), which prefers parsing times over dates. 2000 is a
valid time format (HHMM) but 1999 isn't so it's interpreted as a year.
Use date_parse_from_format() instead.
http://3v4l.org/QvVoR
Previous Comments:
------------------------------------------------------------------------
[2015-04-09 15:38:37] jkronika at gridlined dot com
Description:
------------
When parsing strings containing only a year, it appears that certain ranges of years do not get
parsed appropriately. This is a cause, at least in my case, of very difficult to debug errors.
Test script:
---------------
echo var_export(date_parse('1999'), true)."\n\n";
echo var_export(date_parse('2001'), true);
Expected result:
----------------
array (
'year' => 1999,
'month' => false,
'day' => false,
'hour' => false,
'minute' => false,
'second' => false,
...
)
array (
'year' => 2001,
'month' => false,
'day' => false,
'hour' => false,
'minute' => false,
'second' => false,
...
)
Actual result:
--------------
array (
'year' => 1999,
'month' => false,
'day' => false,
'hour' => false,
'minute' => false,
'second' => false,
...
)
array (
'year' => false,
'month' => false,
'day' => false,
'hour' => 20,
'minute' => 1,
'second' => 0,
...
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69408&edit=1