|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43808 date_create never fails (even when it should)
Submitted: 2008-01-10 18:30 UTC Modified: 2008-01-18 11:58 UTC
From: martin dot contento at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.5 OS: linux
Private report: No CVE-ID: None
 [2008-01-10 18:30 UTC] martin dot contento at gmail dot com
As "karsten" already mentioned ( date_create() never returns FALSE like it is supposed to, even when it is handed complete garbage. It seems to be something like "if the string starts with a letter, treat it as a timezone -> this is not a timezone *dies*)

also, this bug might be related:

Reproduce code:

$date = date_create('asdfasdf');

if ($date instanceof DateTime {
  echo "this is wrong, should be bool";


Expected result:
nothing (i would expect date_create() to handle the error in the timezone function and return FALSE)

Actual result:
Warning: date_create(): Failed to parse time string (asdfasdf) at position 0 (a): The timezone could not be found in the database in /home/mcontento/datetimebug.php on line 3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-17 20:35 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2008-01-18 11:58 UTC] martin dot contento at gmail dot com
Verified to be fixed (in snapshot php5.3-200801180930 and anoncvs->php5).

Thank you very much :)
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 01:01:24 2020 UTC