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

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


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

[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