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

 ID:                 60340
 Updated by:         sala...@php.net
 Reported by:        marcingronowski at gmail dot com
 Summary:            DateTime. The problem of determining the relative
                     dates, by the command last
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Date/time related
 Operating System:   Windows
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

You aren't testing "first/last day of", you're testing "first/last day" which 
simply moves the date defined by the absolute parts forward/backward by one 
day.  
The same applies to your "last monday" test, which should be "last monday of".

All of these behaviours are documented.


Previous Comments:
------------------------------------------------------------------------
[2011-11-19 18:58:22] marcingronowski at gmail dot com

Description:
------------
Incorrect data is generated by function DateTime::__construct in case of using 
the 
relative definition of time.

If you use the command "last day of month" the previous month will be returned.
If you use the command "first day of month" the correct month will be returned 
and 
second day in the month will be returned.

Test script:
---------------
$datea = new DateTime('last day October 2011');
echo $datea->format('Y-F-d');

$dateb = new DateTime('last monday October 2011');
echo $dateb->format('Y-F-d');

$datec = new DateTime('first day October 2011');
echo $datec->format('Y-F-d');

$datec = new DateTime('first day November 2011');
echo $datec->format('Y-F-d');


Expected result:
----------------
2011-October-30
2011-October-30
2011-October-01
2011-November-01


Actual result:
--------------
2011-September-30
2011-September-26
2011-October-02
2011-November-02


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



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

Reply via email to