Bug #67921 [NEW]: createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day
| From: | crazytonyi at gmail dot com | Date: | Thu, 28 Aug 2014 07:32:34 +0000 |
| Subject: | Bug #67921 [NEW]: createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-187308@lists.php.net to get a copy of this message | ||
From: crazytonyi at gmail dot com
Operating system:
PHP version: 5.5.16
Package: Date/time related
Bug Type: Bug
Bug description:createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls
to next day
Description:
------------
When a value between 24 and 99 is in date/time string evaluated by
DateTime:createFromFormat , it handles as valid and resulting object is
Date + hours % 24 . So 36:00 is treated as date + 1 day 12:00
Expected Result: Evaluates to false.
If this is by design, it should be very clearly documented. Since 100:00
returns false, this does not seem intentional.
Test script:
---------------
$time="30:29";
$date = DateTime::createFromFormat("H:m", $time);
echo $date->format(DateTime::W3C);
--
Edit bug report at https://bugs.php.net/bug.php?id=67921&edit=1
--