Bug #51393 [Opn->Asn]: DateTime::createFromFormat() fails if format string contains timezone
| From: | aharvey@php.net | Date: | Fri, 26 Mar 2010 03:57:12 +0000 |
| Subject: | Bug #51393 [Opn->Asn]: DateTime::createFromFormat() fails if format string contains timezone | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-149035@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51393&edit=1
ID: 51393
Updated by: aharvey@php.net
Reported by: jo at feuersee dot de
Summary: DateTime::createFromFormat() fails if format string
contains timezone
-Status: Open
+Status: Assigned
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 5.3.2
-Assigned To:
+Assigned To: aharvey
Previous Comments:
------------------------------------------------------------------------
[2010-03-25 21:19:03] jo at feuersee dot de
Description:
------------
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
information.
- 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]');
print($dt->format('c'));
Expected result:
----------------
1969-03-13T23:40:00+01:00
Actual result:
--------------
Fatal error: Call to a member function format() on a non-object
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51393&edit=1