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

 ID:                 62166
 User updated by:    lenzai2004-dev at yahoo dot fr
 Reported by:        lenzai2004-dev at yahoo dot fr
 Summary:            createfromFormat assign current time by default when
                     reading date only string.
-Status:             Feedback
+Status:             Open
 Type:               Feature/Change Request
 Package:            Date/time related
 Operating System:   Ubuntu 11.10 64bits
 PHP Version:        5.3.13
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for your Help. Sorry for misreading documentation.


Previous Comments:
------------------------------------------------------------------------
[2012-07-07 19:59:41] s...@php.net

The documentation for date_create_from_format states:

! Resets all fields (year, month, day, hour, minute, second, fraction and 
timzone 
information) to the Unix Epoch Without !, all fields will be set to the current 
date and time.

So maybe the format should be !Y-m-d? Would that solve the issue?

------------------------------------------------------------------------
[2012-05-26 10:45:49] lenzai2004-dev at yahoo dot fr

Description:
------------
DateTime:createFromFormat() and DateTime::__construct are not consistent for 
parsing dates.

__construct sets default time at 00:00:00
DateTime::createFromFormat() sets default time at current time

Test script:
---------------
var_export(DateTime::createFromFormat("Y-m-d","2012-05-11"));
var_export(new DateTime("2012-05-11"));


Expected result:
----------------
DateTime::__set_state(array(
   'date' => '2012-05-11 00:00:00',
   'timezone_type' => 3,
   'timezone' => 'Asia/Chongqing',
))
        DateTime::__set_state(array(
   'date' => '2012-05-11 00:00:00',
   'timezone_type' => 3,
   'timezone' => 'Asia/Chongqing',
))

Actual result:
--------------
DateTime::__set_state(array(
   'date' => '2012-05-11 18:34:45',
   'timezone_type' => 3,
   'timezone' => 'Asia/Chongqing',
))
        DateTime::__set_state(array(
   'date' => '2012-05-11 00:00:00',
   'timezone_type' => 3,
   'timezone' => 'Asia/Chongqing',
))


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62166&edit=1

Reply via email to