Edit report at https://bugs.php.net/bug.php?id=53294&edit=1
ID: 53294 Comment by: maarten at react dot com Reported by: maarten at react dot com Summary: DateTime->setTimezone() very slow far future dates Status: Feedback Type: Bug Package: Date/time related Operating System: 64 bit Centos PHP Version: 5.2.14 Assigned To: derick Block user comment: N Private report: N New Comment: Tested in 5.3.6, and appears to be fixed. $date = new DateTime('@'.(int)(PHP_INT_MAX / 2)); now takes less than 1ms. :) Previous Comments: ------------------------------------------------------------------------ [2011-01-22 08:52:50] s...@php.net Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [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 https://bugs.php.net/bug.php?id=53294&edit=1