ID:               47846
 Updated by:       der...@php.net
 Reported By:      brooksie155 at yahoo dot com
 Status:           Feedback
 Bug Type:         Date/time related
 Operating System: CentOS
 PHP Version:      5.2CVS-2009-03-31 (snap)
 New Comment:

Just as a comment to Rasmus, that's not true. The format "2009-02"
implicitly sets the day nr as 1.


Previous Comments:
------------------------------------------------------------------------

[2009-03-31 08:56:25] der...@php.net

I can not reproduce this, what does the following output:

<?php
$str = "2009-02";
echo date_default_timezone_get(), "\n";
var_dump( date_parse( $str ) );
$date = new DateTime( $str );
echo $date->format( DateTime::ISO8601 ), "\n";
?>

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

[2009-03-31 08:56:02] ras...@php.net

Not a bug.  As documented, this defaults to now and you can override
individual components in the constructor.  In your case you have chosen
Feb. 2009, but didn't specify a day of the month.  PHP picks todays day,
which is the 31st day of the month.  The 31st day of Feb will fall in
March since Feb doesn't have 31 days.

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

[2009-03-31 08:44:45] brooksie155 at yahoo dot com

Description:
------------
There is a bug in the constructor of this object if you are only
specifying the month and the year when dealing with the month of
February.





Reproduce code:
---------------
$date = new DateTime('2009-02');
echo $date->format('Y-m');

Expected result:
----------------
2009-02

Actual result:
--------------
2009-03


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


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

Reply via email to