[PHP-BUG] Bug #51393 [NEW]: DateTime::createFromFormat() fails if format string contains timezone
[email protected] ("jo at feuersee dot de")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From:
Operating system: Linux
PHP version: 5.3.2
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::createFromFormat() fails if format string contains timezone
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 bug report at http://bugs.php.net/bug.php?id=51393&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51393&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51393&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51393&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51393&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51393&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51393&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51393&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51393&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51393&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51393&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51393&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51393&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51393&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51393&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51393&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51393&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51393&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51393&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51393&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51393&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51393&r=mysqlcfg