ID: 28599
User updated by: fr33k at techie dot com
-Summary: strtotime fails with certain intervals
Reported By: fr33k at techie dot com
Status: Open
Bug Type: Date/time related
Operating System: Debian
PHP Version: 4.3.5
New Comment:
Sorry, pasted the "actual result" in the description.
Previous Comments:
------------------------------------------------------------------------
[2004-06-01 07:49:36] fr33k at techie dot com
Description:
------------
When strtotime encounters certain intervals while using a zero "now"
time as the second argument, it fails. Some intervals fail, others work
fine. All worked fine with a non-zero "now" date. I was using this as a
convenient way to translate intervals like "+1 Week" into seconds.
0+1 Day: 86400
0+2 Days: 172800
+3 Days: 1086327304
104022382+3 Days: 104281582
0+3 Days: -1
+332 Days: 1114752904
0+332 Days: -1
0+1 Week: -1
0+4 Weeks: -1
0+1 Month: 2678400
0+3 Months: 7776000
0+1 Year: 31536000
0+4 Years: 126230400
Reproduce code:
---------------
print "0+2 Days: ".strtotime('+2 Days',0)."\n";
print "+3 Days: ".strtotime('+3 Days')."\n";
print "104022382+3 Days: ".strtotime('+3 Days',104022382)."\n";
print "0+3 Days: ".strtotime('+3 Days',0)."\n";
print "+332 Days: ".strtotime('+332 Days')."\n";
print "0+332 Days: ".strtotime('+332 Days',0)."\n";
print "0+1 Week: ".strtotime('+1 Week',0)."\n";
print "0+4 Weeks: ".strtotime('+4 Weeks',0)."\n";
print "0+3 Months: ".strtotime('+3 Months',0)."\n";
print "0+1 Year: ".strtotime('+1 Year',0)."\n";
Expected result:
----------------
0+2 Days: 172800
+3 Days: 1086327494
104022382+3 Days: 104281582
0+3 Days: 259200
+332 Days: 1114753094
0+332 Days: 28684800
0+1 Week: 604800
0+4 Weeks: 2419200
0+3 Months: 7776000
0+1 Year: 31536000
Actual result:
--------------
0+2 Days: 172800
+3 Days: 1086327494
104022382+3 Days: 104281582
0+3 Days: -1
+332 Days: 1114753094
0+332 Days: -1
0+1 Week: -1
0+4 Weeks: -1
0+3 Months: 7776000
0+1 Year: 31536000
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28599&edit=1