From:             hoang dot nguyen at groupion dot com
Operating system: Windows, Linux
PHP version:      5.4Git-2012-08-22 (snap)
Package:          Date/time related
Bug Type:         Bug
Bug description:"DateTime->modify('+0 days')" Modifies DateTime Object

Description:
------------
Calling "modify()" with a delta of 0 should not change the time, regardless
of whether a time zone was defined for the DateTime object or not, and
independent from how the object was created (from a UNIX timestamp or a
date/time string with or without time zone).


Test script:
---------------
See long version with more details and possible regressions here:
http://pastebin.com/v8RybhVh

Below is a short excerpt for the current bug.

<?php
  echo "FROM TIMESTAMP, NO TZ:\n";

  $date = new DateTime('@'.strtotime('2012-08-22 00:00:00 CEST'));
  echo $date->format('Y-m-d H:i:s T').' (offset
'.$date->getOffset().")\n";

  $date->modify('+0 days');
  echo $date->format('Y-m-d H:i:s T').' (offset
'.$date->getOffset().")\n";
?>


Expected result:
----------------
FROM TIMESTAMP, NO TZ:
2012-08-21 22:00:00 GMT+0000 (offset 0)  <-- should be equal
2012-08-21 22:00:00 GMT+0000 (offset 0)  <-- to this
FROM TIMESTAMP, WITH TZ:
2012-08-22 00:00:00 CEST (offset 7200)
2012-08-22 00:00:00 CEST (offset 7200)
FROM STRING:
2012-08-22 00:00:00 CEST (offset 7200)
2012-08-22 00:00:00 CEST (offset 7200)


Actual result:
--------------
Output from PHP 5.4.4, 5.4.6 and snapshot r4e56105 from August 22, 2012:

FROM TIMESTAMP, NO TZ:
2012-08-21 22:00:00 GMT+0000 (offset 0)  <-- different 
2012-08-21 23:00:00 GMT+0000 (offset 0)  <-- from this
FROM TIMESTAMP, WITH TZ:
2012-08-22 00:00:00 CEST (offset 7200)
2012-08-22 00:00:00 CEST (offset 7200)
FROM STRING:
2012-08-22 00:00:00 CEST (offset 7200)
2012-08-22 00:00:00 CEST (offset 7200)

In PHP 5.2.0, the bug appears when creating DateTime from a string (with
time zone), which one might test as well to guard against similar bugs:

FROM TIMESTAMP, NO TZ:
2012-08-21 22:00:00 GMT+0100 (offset 7200)
2012-08-21 22:00:00 GMT+0100 (offset 7200)
FROM TIMESTAMP, WITH TZ:
2012-08-22 00:00:00 CEST (offset 7200)
2012-08-22 00:00:00 CEST (offset 7200)
FROM STRING:
2012-08-22 00:00:00 CEST (offset 7200)  <-- different
2012-08-21 23:00:00 CEST (offset 7200)  <-- from this


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

Reply via email to