Edit report at https://bugs.php.net/bug.php?id=53294&edit=1
ID: 53294
User updated by: maarten at react dot com
Reported by: maarten at react dot com
Summary: DateTime->setTimezone() very slow far future dates
-Status: Feedback
+Status: Closed
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:
I confirmed it was already fixed in 5.3.6, and a 3rd person (php dot net at
doppy dot nl) confirmed it for 5.3.10, so issue is resolved. :)
Previous Comments:
------------------------------------------------------------------------
[2012-03-21 16:48:21] php dot net at doppy dot nl
Seems to be fixed for me as well.
------------
PHP 5.3.10-1ubuntu2 with Suhosin-Patch (cli) (built: Mar 5 2012 18:27:21)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
on 64bit.
------------------------------------------------------------------------
[2011-07-25 14:36:07] maarten at react dot com
Tested in 5.3.6, and appears to be fixed.
$date = new DateTime('@'.(int)(PHP_INT_MAX / 2));
now takes less than 1ms. :)
------------------------------------------------------------------------
[2011-01-22 08:52:50] [email protected]
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