ID: 47909
Updated by: [email protected]
Reported By: asylow at free dot fr
-Status: Open
+Status: Bogus
Bug Type: Date/time related
Operating System: windows XP
PHP Version: 5.2.9
New Comment:
This is how it is supposed to work. The relative date modifiers are for
*clock time*, not *real time*.
Previous Comments:
------------------------------------------------------------------------
[2009-04-06 14:17:51] asylow at free dot fr
Description:
------------
Hi,
When adding +2 hours to '2009-10-25 01:00:00', '03:00:00' is obtained,
skipping the second '02:00:00' that exists during that night.
Reproduce code:
---------------
Comparison between using +1 hour to the object and adding +3600 to the
timestamp :
<?php
$date1 = '2009-10-25 01:00:00';
$obj_date = date_create($date1);
$timestamp = strtotime($date1);
$timestamp += 3600;
$obj_date->modify('+1 hour');
echo '+1 hour<br>';
echo 'timestamp : ' . date('H:i:s',$timestamp) . ' ' . $timestamp .
'<br/>';
echo 'date_obj : ' . $obj_date->format('H:i:s') . ' ' .
$obj_date->format('U') . '<br><br>';
echo '+2 hours<br>';
$timestamp += 3600;
$obj_date->modify('+1 hour');
echo 'timestamp : ' . date('H:i:s',$timestamp) . ' ' . $timestamp .
'<br/>';
echo 'date_obj : ' . $obj_date->format('H:i:s') . ' ' .
$obj_date->format('U') . '<br><br>';
?>
Expected result:
----------------
+1 hour
timestamp : 02:00:00 1256428800
date_obj : 02:00:00 1256432400
+2 hours
timestamp : 02:00:00 1256432400
date_obj : 02:00:00 1256432400
Actual result:
--------------
+1 hour
timestamp : 02:00:00 1256428800
date_obj : 02:00:00 1256432400
+2 hours
timestamp : 02:00:00 1256432400
date_obj : 03:00:00 1256436000
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47909&edit=1