Edit report at http://bugs.php.net/bug.php?id=53294&edit=1

 ID:                 53294
 Updated by:         der...@php.net
 Reported by:        maarten at react dot com
 Summary:            DateTime->setTimezone() very slow far future dates
-Status:             Open
+Status:             Assigned
 Type:               Bug
 Package:            Date/time related
 Operating System:   64 bit Centos
 PHP Version:        5.2.14
-Assigned To:        
+Assigned To:        derick
 Block user comment: N



Previous Comments:
------------------------------------------------------------------------
[2010-11-11 13:55:30] maarten at react dot com

Description:
------------
DateTime->setTimezone() is very slow on dates in the far future (or
history), and the time needed isnt monotonic for greater dates.



ie. setTimezone() on a DateTime(PHP_INT_MAX) /* 64 bit max */ takes 0.05
seconds, but takes 250 whole seconds for PHP_INT_MAX/2 .



Using the $timezone parameter of the DateTime constructor is always fast
though.

Test script:
---------------
        $start = microtime(1);

        $date = new DateTime('@'.(PHP_INT_MAX));

//      $date = new DateTime('@'.(int)(PHP_INT_MAX / 2));

        $date->setTimezone(new DateTimeZone('Europe/Amsterdam'));



        echo microtime(1) - $start;

Expected result:
----------------
A faster change of the timezone; performance equal to using the
constructor parameter



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53294&edit=1

Reply via email to