From:             aj at dl10design dot co dot uk
Operating system: Centos 5
PHP version:      5.3.1
PHP Bug Type:     Date/time related
Bug description:  setTime on a DateTime object reapplying DateTime::sub()

Description:
------------
When using set time after modifying the date by using sub, the sub is 
re-applied as well.

Reproduce code:
---------------
date_default_timezone_set('Europe/London');

$datetime = new DateTime('2010-02-19 14:52:10');

$datetime->sub(new DateInterval("P2D"));
// Date should now be 2010-02-17
echo $datetime->format("Y-m-d H:i:s") . "<br />";

$datetime->setTime(15,0,0);
// Date and time should now be 2010-02-17 15:00:00
// BUT it is 2010-02-15 15:00:00
echo $datetime->format("Y-m-d H:i:s");

Expected result:
----------------
Only the time should have be changed

Actual result:
--------------
Day and date are changed.

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

Reply via email to