|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51393 DateTime::createFromFormat() fails if format string contains timezone
Submitted: 2010-03-25 21:19 UTC Modified: 2010-03-26 05:31 UTC
From: jo at feuersee dot de Assigned: aharvey (profile)
Status: Closed Package: Date/time related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jo at feuersee dot de
New email:
PHP Version: OS:


 [2010-03-25 21:19 UTC] jo at feuersee dot de
I was trying to process Apache logfiles with PHP. The default LogFormat timestamp
%t translates to '[d/M/Y:H:i:s O]' in date() notation.
PHP fails to create DateTime instances if the format argument contains timezone
placeholders like O P e

I am aware of the 3rd parameter of DateTime::createFromFormat() to pass timezone
- the documentation says 'Format accepted by date()'
- DateTime is supposed to help parsing datetime formats, not to restrict

Test script:
$dt = DateTime::createFromFormat('[d/M/Y:H:i:s O]', '[13/Mar/1969:23:40:00 +0100]');

Expected result:

Actual result:
Fatal error: Call to a member function format() on a non-object


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-26 04:57 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: aharvey
 [2010-03-26 05:31 UTC]
Automatic comment from SVN on behalf of aharvey
Log: Fixed bug #51393 (DateTime::createFromFormat() fails if format string contains timezone).
 [2010-03-26 05:31 UTC]
-Status: Assigned +Status: Closed
 [2010-03-26 05:31 UTC]
This bug has been fixed in SVN.

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.

 [2010-03-26 11:12 UTC]
Automatic comment from SVN on behalf of aharvey
Log: Backported the fix for bug #51393 (DateTime::createFromFormat() fails if format
string contains timezone) to PHP_5_2 per discussion with Derick.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 18:01:36 2024 UTC