php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67324 DateTime::createFromFormat wrong result
Submitted: 2014-05-22 11:42 UTC Modified: 2014-05-22 21:48 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: volny dot licvin at gmail dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
41 + 10 = ?
Subscribe to this entry?

 
 [2014-05-22 11:42 UTC] volny dot licvin at gmail dot com
Description:
------------
DateTime::createFromFormat not checking properly provided format (day [01-31] and month [01-12] limitations) and only checking number of digits. 

Test script:
---------------
<?php
var_dump(DateTime::createFromFormat('Y-m-d', '9999-99-99'));

Expected result:
----------------
bool(false)

Actual result:
--------------
object(DateTime)#9 (3) {
  ["date"]=>
  string(20) "10007-06-07 13:28:21"
  ["timezone_type"]=>
  int(3)
  ["timezone"]=>
  string(13) "Europe/Berlin"
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-05-22 21:48 UTC] aharvey@php.net
-Status: Open +Status: Wont fix -Package: *General Issues +Package: Date/time related
 [2014-05-22 21:48 UTC] aharvey@php.net
createFromFormat(), like other functions that parse free text date strings, will wrap out of range values rather than generating errors, so long as they match the expected format (in terms of number of digits).
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 02:05:44 2022 UTC