|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-06 14:22 UTC] derick@php.net
[2009-04-07 07:46 UTC] asylow at free dot fr
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 22:00:01 2025 UTC |
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