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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 07:01:30 2024 UTC