Edit report at https://bugs.php.net/bug.php?id=63615&edit=1
ID: 63615 Updated by: der...@php.net Reported by: flavius dot as at gmail dot com Summary: DateTime::modify() ignores timezone Status: Assigned Type: Bug Package: Date/time related Operating System: Linux x64 PHP Version: 5.4.9 Assigned To: derick Block user comment: N Private report: N New Comment: The original idea behind modify was to only add specific hours, minutes, days etc. and not to *set* specific values such as timezones (or year, month, etc). I am therefore leaning to saying to this patch: "this is not how things are supposed to work". Previous Comments: ------------------------------------------------------------------------ [2012-11-26 21:42:36] flavius dot as at gmail dot com Description: ------------ DateTime::modify() ignores the timezone (when using the RFC 2822 format for instance). The right timestamp should be $t1 (from the example below). Test script: --------------- <?php $str = "Tue, 10 Apr 2012 11:27:56 +0300"; $d1 = new DateTime($str); $d2 = new DateTime; $d2->modify($str); $t1 = $d1->getTimestamp(); $t2 = $d2->getTimestamp(); $tz1 = $d1->getTimezone()->getName(); $tz2 = $d2->getTimezone()->getName(); $f1 = $d1->format(DateTime::RFC2822); $f2 = $d2->format(DateTime::RFC2822); var_dump(compact('t1', 't2', 'tz1', 'tz2', 'f1', 'f2')); /* array(6) { 't1' => int(1334046476) 't2' => int(1334050076) 'tz1' => string(6) "+03:00" 'tz2' => string(13) "Europe/Vienna" 'f1' => string(31) "Tue, 10 Apr 2012 11:27:56 +0300" 'f2' => string(31) "Tue, 10 Apr 2012 11:27:56 +0200" } */ Expected result: ---------------- $t1 == $t2 Actual result: -------------- $t1 != $t2 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63615&edit=1