php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47909 summer hour withda date object
Submitted: 2009-04-06 14:17 UTC Modified: 2009-04-07 07:46 UTC
From: asylow at free dot fr Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.9 OS: windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: asylow at free dot fr
New email:
PHP Version: OS:

 

 [2009-04-06 14:17 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 14:22 UTC] derick@php.net
This is how it is supposed to work. The relative date modifiers are for *clock time*, not *real time*. 
 [2009-04-07 07:46 UTC] asylow at free dot fr
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 ?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC