|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67921 createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day
Submitted: 2014-08-28 07:32 UTC Modified: 2014-08-28 16:28 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: crazytonyi at gmail dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.5.16 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: crazytonyi at gmail dot com
New email:
PHP Version: OS:


 [2014-08-28 07:32 UTC] crazytonyi at gmail dot com
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:
$date =  DateTime::createFromFormat("H:m", $time);
echo $date->format(DateTime::W3C);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-28 16:28 UTC]
-Type: Bug +Type: Documentation Problem
 [2014-08-28 16:28 UTC]
This is standard behavior for date functions: when the input matches the format constraints (eg, 'H' is a two-digit number) then numbers above and below the valid range will over-/underflow.
"100:00" isn't valid for "H:m" because the hour cannot be three digits.
 [2020-08-03 22:40 UTC] thomas at landauer dot at
I just opened a related issue:
 [2022-05-13 14:27 UTC]
Automatic comment on behalf of derickr
Log: Fixed bug #67921: createFromFormat allows overflow for 'H' and 'G' so 25-99 rolls to next day
 [2022-05-13 14:27 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC