From:             fr33k at techie dot com
Operating system: Debian
PHP version:      4.3.5
PHP Bug Type:     Date/time related
Bug description:  strtotime fails with certain intervals

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 bug report at http://bugs.php.net/?id=28599&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28599&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28599&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28599&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28599&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28599&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28599&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28599&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28599&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28599&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28599&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28599&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28599&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28599&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28599&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28599&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28599&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28599&r=float

Reply via email to