|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48611 strtotime very slow with large values
Submitted: 2009-06-19 19:13 UTC Modified: 2009-06-28 01:00 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: evert at rooftopsolutions dot nl Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.10 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
21 + 26 = ?
Subscribe to this entry?

 [2009-06-19 19:13 UTC] evert at rooftopsolutions dot nl
strtotime is very slow with very large values.

Reproduce code:
php -r "echo strtotime('-50000000000 days');"

also, to clearly see this function has O(n) instead of O(1) complexity.

for x in {1..40}; do php -r "echo $x, \"\t\", pow ( 2, $x ), \"\t\", strtotime ( ( -1 * pow ( 2, $x ) ) . ' days' ), \"\n\";" 2> /dev/null; done;

Regardless of the fact you won't often work with dates 130 million years ago, this could be used to trigger a dos-like attack.

Expected result:
Quick results

Actual result:
veryyy slow results :)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-20 01:24 UTC]
Please try using this CVS snapshot:
For Windows:

Pretty sure this is fixed in 5.3
 [2009-06-28 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jan 17 19:03:34 2022 UTC