Bug->Doc #51866 [Opn]: DateTime::createFromFormat does not match documentation
| From: | salathe@php.net | Date: | Thu, 20 May 2010 08:20:06 +0000 |
| Subject: | Bug->Doc #51866 [Opn]: DateTime::createFromFormat does not match documentation | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4408@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51866&edit=1
ID: 51866
Updated by: salathe@php.net
Reported by: smalyshev at sugarcrm dot com
Summary: DateTime::createFromFormat does not match
documentation
Status: Open
-Type: Bug
+Type: Documentation Problem
Package: Date/time related
Operating System: *
PHP Version: 5.3SVN-2010-05-20 (SVN)
-Assigned To:
+Assigned To: derick
New Comment:
I believe this is an issue of documentation rather than implementation,
the quoted
portion of the manual describes different behaviour than what the code
appears to
do. I'll assign this to Derick to confirm one way or the other.
Previous Comments:
------------------------------------------------------------------------
[2010-05-20 04:02:19] stas@php.net
It also would be nice if this function could ignore extra input after
the parsing and/or return where it stopped.
------------------------------------------------------------------------
[2010-05-20 04:01:27] smalyshev at sugarcrm dot com
Description:
------------
The manual for DateTime::createFromFormat says:
Format accepted by date().
If format does not contain the character ! then portions of the
date/time value specified in format but not specified in time will be
set to the current system time.
However if you specify format like "d-m-Y H:i" and provide datetime
string that does not contain time, parsing would fail - even though the
manual says if time string does not contain parts from format it should
use current system.
Test script:
---------------
<?php
$date = DateTime::createFromFormat("d-m-Y H:i", "25-10-2007");
var_dump($date);
Expected result:
----------------
Something like:
object(DateTime)#1 (3) {
["date"]=>
string(19) "2007-10-25 18:58:31"
["timezone_type"]=>
int(3)
["timezone"]=>
string(19) "America/Los_Angeles"
}
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51866&edit=1