|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-05-16 23:51 UTC] kavi at postpro dot net
[2014-01-17 13:59 UTC] jimmyraynor at gmail dot com
[2014-01-17 14:57 UTC] derick@php.net
-Assigned To:
+Assigned To: derick
[2017-03-19 10:14 UTC] heiglandreas@php.net
-Status: Assigned
+Status: Duplicate
[2017-03-19 10:14 UTC] heiglandreas@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
Description: ------------ If you're using a timezone, like Europe/Paris, with summer and winter times, you will obtain a wrong result when adding and subtracting a time interval on a date at summertime threshold. I fixed that issue by making all operations on GMT timezone. Test script: --------------- date_default_timezone_set('Europe/Paris'); /* Get a time just on the threshold */ $d = new DateTime("2012-03-25 03:00:00"); echo $d->format(DateTime::RFC2822) . "\n"; /* Substract one hour */ $i = new DateInterval("PT1H"); $d->sub($i); echo $d->format(DateTime::RFC2822) . "\n"; Expected result: ---------------- Sun, 25 Mar 2012 03:00:00 +0200 Sun, 25 Mar 2012 01:00:00 +0100 Actual result: -------------- Sun, 25 Mar 2012 03:00:00 +0200 Sun, 25 Mar 2012 03:00:00 +0200