Bug #66825 [NEW]: DateTime::createFromFormat not work as documentation example and more cases
| From: | nadavvin at gmail dot com | Date: | Wed, 05 Mar 2014 13:28:37 +0000 |
| Subject: | Bug #66825 [NEW]: DateTime::createFromFormat not work as documentation example and more cases | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184531@lists.php.net to get a copy of this message | ||
From: nadavvin at gmail dot com
Operating system: windows, linux
PHP version: 5.4.25
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::createFromFormat not work as documentation example and more cases
Description:
------------
problems with DateTime::createFromFormat:
1) example create the date in 1970 instead of 2009
2) failed to create date object from my trying to do format:
'Y-m-d?H:i:sP'
Test script:
---------------
<?php
//example #2 from
http://il1.php.net/manual/en/datetime.createfromformat.php
$format = 'Y-m-!d H:i:s';
$date = DateTime::createFromFormat($format, '2009-02-15 15:16:17');
echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
//my trying to create from DateTime::RFC3339 format
$dt = new DateTime(null,new DateTimeZone('gmt'));
//$time = $dt->format(DateTime::RFC3339);
$time = $dt->format('Y-m-d\TH:i:sP');
echo $time."\n";
$dt = DateTime::createFromFormat($time, 'Y-m-d?H:i:sP');
//$dt = DateTime::createFromFormat($time, DateTime::RFC3339);
var_dump($dt);
Expected result:
----------------
1) Format: Y-m-!d H:i:s; 2009-02-15 15:16:17
2) not false in var_dump($dt);
Actual result:
--------------
1) Format: Y-m-!d H:i:s; 1970-01-15 15:16:17
2) DateTime object dump
--
Edit bug report at https://bugs.php.net/bug.php?id=66825&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66825&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66825&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66825&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66825&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66825&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66825&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66825&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66825&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66825&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66825&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66825&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66825&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66825&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66825&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66825&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66825&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66825&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66825&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66825&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66825&r=mysqlcfg