Edit report at http://bugs.php.net/bug.php?id=51866&edit=1

 ID:               51866
 Updated by:       s...@php.net
 Reported by:      smalyshev at sugarcrm dot com
 Summary:          DateTime::createFromFormat does not match
                   documentation
 Status:           Open
 Type:             Bug
 Package:          Date/time related
 Operating System: *
 PHP Version:      5.3SVN-2010-05-20 (SVN)

 New Comment:

It also would be nice if this function could ignore extra input after
the parsing and/or return where it stopped.


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to