From:             brian dot feaver at sellingsource dot com
Operating system: Mac OS X
PHP version:      5.3.20
Package:          Date/time related
Bug Type:         Bug
Bug description:DateTime:setDate() date not used after modify("last day of...")

Description:
------------
When modifying a DateTime object with modify("last day of last month")
syntax and 
followed by a setDate(), the date portion of setDate() is ignored. It
modifies the 
year and the month, but continues to set the day portion to the last day of
the 
month.

If modify() is called with the absolute date instead of setDate(), it
correctly 
sets the date.

Test script:
---------------
<?php
$date = new DateTime('2012-03-30');

$date->modify("last day of last month");
var_dump($date->format('Y-m-d')); // correctly last day of Feb

$date->setDate(2012, 1, 30);
var_dump($date->format('Y-m-d')); // incorrect date

$date->modify('2012-01-30');
var_dump($date->format('Y-m-d')); // does set correct date


Expected result:
----------------
string(10) "2012-02-29"
string(10) "2012-01-30"
string(10) "2012-01-30"

Actual result:
--------------
string(10) "2012-02-29"
string(10) "2012-01-31"
string(10) "2012-01-30"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=63863&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63863&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63863&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63863&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63863&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63863&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63863&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63863&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63863&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63863&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63863&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63863&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63863&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63863&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63863&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63863&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63863&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63863&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63863&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63863&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63863&r=mysqlcfg

Reply via email to