Bug #66825 [Opn->Nab]: DateTime::createFromFormat not work as documentation example and more cases
| From: | derick@php.net | Date: | Wed, 05 Mar 2014 16:05:53 +0000 |
| Subject: | Bug #66825 [Opn->Nab]: DateTime::createFromFormat not work as documentation example and more cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184534@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66825&edit=1
ID: 66825
Updated by: derick@php.net
Reported by: nadavvin at gmail dot com
Summary: DateTime::createFromFormat not work as documentation
example and more cases
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: windows, linux
PHP Version: 5.4.25
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You have the ! in your format (before the "d"), which is documented at the URL you're
pointed to as:
! Resets all fields (year, month, day, hour, minute, second, fraction and timzone information) to
the Unix Epoch
Previous Comments:
------------------------------------------------------------------------
[2014-03-05 13:28:37] nadavvin at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=66825&edit=1