ID:               45409
 Updated by:       der...@php.net
 Reported By:      jerico dot dev at gmail dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         Date/time related
 Operating System: *
 PHP Version:      5.*, 6CVS (2008-12-09)
 Assigned To:      derick
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

This seems to be a duplicate of bug #48522, which is now fixed in CVS.

I now get the following result with your original code.

0.000047
0.000079



Previous Comments:
------------------------------------------------------------------------

[2009-02-04 13:47:36] php at wallbash dot com

Hi,

i hope i don't bug you but do you know when this might get fixed or is
there a patch available ? We (finally) moved to 5.2 and this is a
showstopper for us and would (sadly) require lots of refactoring.

Thanks

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

[2008-07-01 21:30:28] der...@php.net

I'll have a look at this, but there is even a MUCH faster way:

<?php
$d = new DateTime( '1902-03-25 18:25:25' );
$mt0 = microtime(true);

$d->modify( '+1 year' );
$mt1 = microtime(true);
$d->modify( '+1 year' );
$mt2 = microtime(true);
printf("%.6f\r\n%.6f\r\n", $mt1-$mt0, $mt2-$mt1);
?>
0.013312/0.696215 for your code, vs 0.000065/0.000028 for my approach.

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

[2008-07-01 20:55:08] jerico dot dev at gmail dot com

Description:
------------
strtotime() performs 3 orders of magnitude slower when operating on a
timestamp.

Reproduce code:
---------------
$string = '1902-03-25 18:25:25';
$timestamp = strtotime($string); 

$mt0 = microtime(true);
$result1 = strtotime("$string +1 year");
$mt1 = microtime(true);
$result2 = strtotime("+1 year", $timestamp);
$mt2 = microtime(true);
printf("%.6f\r\n%.6f\r\n", $mt1-$mt0, $mt2-$mt1);

// This will output
// 0.000171
// 0.721877
// on my machine

Actual result:
--------------
see reproduce code


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


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

Reply via email to