#47909 [Bgs]: summer hour withda date object
| From: | asylow at free dot fr | Date: | Tue, 07 Apr 2009 07:46:40 +0000 |
| Subject: | #47909 [Bgs]: summer hour withda date object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135617@lists.php.net to get a copy of this message | ||
ID: 47909
User updated by: asylow at free dot fr
Reported By: asylow at free dot fr
Status: Bogus
Bug Type: Date/time related
Operating System: windows XP
PHP Version: 5.2.9
New Comment:
Thank you for the answer.
Well that doesn't make sense to me and that's quite tricky.
I don't see a case where i would need to know what would be the next
hour number on a clock.
The logical usage would be me moving through time and needing to know
what time it is.
Is the behaviour referenced somewhere ?
Previous Comments:
------------------------------------------------------------------------
[2009-04-06 14:22:19] derick@php.net
This is how it is supposed to work. The relative date modifiers are for
*clock time*, not *real time*.
------------------------------------------------------------------------
[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