Bug #68286 [NEW]: DateTime::sub crossing DST border starts to add

From: Date: Wed, 22 Oct 2014 15:41:17 +0000
Subject: Bug #68286 [NEW]: DateTime::sub crossing DST border starts to add
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188263@lists.php.net to get a copy of this message
From:             sam at strictlyphp dot com
Operating system: Irrelevant
PHP version:      Irrelevant
Package:          *General Issues
Bug Type:         Bug
Bug description:DateTime::sub crossing DST border starts to add

Description:
------------
Starting with a date in standard time and subtracting over the DST
"border", suddenly adds time.
Line 5 in the actual result below seems to be wrong.
Happens in all PHP versions from 5.4.24 & 5.5.8 onwards.

Test script:
---------------
$tz = new DateTimeZone('Europe/Brussels');
$date = new DateTime('2014-10-26T03:00:00', $tz);
$interval = new DateInterval('PT30M');

for ($i = 0; $i < 5; $i++) {
	echo $date->sub($interval)->format('c e T') . PHP_EOL;
}

Expected result:
----------------
2014-10-26T02:30:00+01:00 Europe/Brussels CET
2014-10-26T02:00:00+01:00 Europe/Brussels CET
2014-10-26T02:30:00+02:00 Europe/Brussels CEST
2014-10-26T02:00:00+02:00 Europe/Brussels CEST
2014-10-26T01:30:00+02:00 Europe/Brussels CEST

Actual result:
--------------
2014-10-26T02:30:00+01:00 Europe/Brussels CET
2014-10-26T02:00:00+01:00 Europe/Brussels CET
2014-10-26T02:30:00+02:00 Europe/Brussels CEST
2014-10-26T02:00:00+02:00 Europe/Brussels CEST
2014-10-26T02:30:00+02:00 Europe/Brussels CEST

-- 
Edit bug report at https://bugs.php.net/bug.php?id=68286&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68286&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68286&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68286&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68286&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68286&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68286&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68286&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68286&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68286&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68286&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68286&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68286&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68286&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68286&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68286&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68286&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68286&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68286&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68286&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68286&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#188263) next »