|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-11-27 23:01 UTC] andrewpate08 at hotmail dot com
Description:
------------
British summertime does not actually end until....
27-10-2013 01:59:59+01:00 (BST)
at which point, one second later it kicks back to GMT...
27-10-2013 01:00:00+00:00 (GMT)
It seems calculations involving DateTime->add() and the 'Europe/London' DateTimeZone crossing the END of British summertime (BST) gives an incorrect result.
On the day British summertime ends it is not until 2:00AM (BST) which is 1:00AM (GMT) that clocks switch from BST to GMT (i.e. go back from 2:00 to 1:00)
Test script:
---------------
<?php
$start = new DateTime("2013-10-27 00:55:00", new DateTimeZone('Europe/London'));
$step = DateInterval::createFromDateString("600 seconds");
echo "start = " . $start->format('d-m-Y H:i:sP') . "<br />";
$start->add($step);
echo "start = " . $start->format('d-m-Y H:i:sP') . "<br />";
?>
Expected result:
----------------
start = 27-10-2013 00:55:00+01:00
start = 27-10-2013 01:05:00+00:00
Actual result:
--------------
start = 27-10-2013 00:55:00+01:00
start = 27-10-2013 01:05:00+01:00
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 02:00:01 2025 UTC |
A workround is to switch to UTC to do the arithmetic, something like... $originalTimezone = $targetDateTime -> getTimezone(); $targetDateTime -> setTimezone(new DateTimeZone('UTC')); $targetDateTime -> add($durationAsDateInterval); //add $targetDateTime -> setTimezone($originalTimezone);