From:             mikeb at tracersinfo dot com
Operating system: Win32 (XP2) and Linux
PHP version:      5.1.2
PHP Bug Type:     Date/time related
Bug description:  strtotime unconditional false return on now <= 0

Description:
------------
Despite recent modifications to the date functions that now allow negative
timestamps in both of my environments (Win32 and Linux) [THANK YOU, btw!],
strtotime() returns false any time the "now" parameter evaluates to 0 or
less, even when it clearly demonstrates it can perform the calculation
requested and the date/time in question is within reasonable bounds.

Reproduce code:
---------------
<?php

$a["mktime(1, 2, 3, 4, 5, 1967)"] = mktime(1, 2, 3, 4, 5, 1967);
$a["strtotime('-10 years', 0)"] = strtotime('-10 years', 0);
$a["strtotime('-10 years', 1)"] = strtotime('-10 years', 1);
$a["strtotime('+10 years', 0)"] = strtotime('+10 years', 0);
$a["strtotime('+10 years', 1)"] = strtotime('+10 years', 1);
$a["gmmktime(0, 0, 0, 1, 1, 1970)"] = gmmktime(0, 0, 0, 1, 1, 1970);
$a["strtotime('-10 years', gmmktime(0, 0, 0, 1, 1, 1970))"] =
strtotime('-10 years', gmmktime(0, 0, 0, 1, 1, 1970));
$a["strtotime('12/31/1969 19:00:00 -10 years')"] = strtotime('12/31/1969
19:00:00 -10 years');
$a["strtotime('+10 years', gmmktime(0, 0, 0, 1, 1, 1965))"] =
strtotime('+10 years', gmmktime(0, 0, 0, 1, 1, 1965));
$a["strtotime('12/31/1964 19:00:00 +10 years')"] = strtotime('12/31/1964
19:00:00 +10 years');
var_dump($a);

?>

Expected result:
----------------
array(10) {
  ["mktime(1, 2, 3, 4, 5, 1967)"]=>
  int(-86551077)
  ["strtotime('-10 years', 0)"]=>
  int(-315619200)  <------
  ["strtotime('-10 years', 1)"]=>
  int(-315619199)
  ["strtotime('+10 years', 0)"]=>
  int(315532800)  <-------
  ["strtotime('+10 years', 1)"]=>
  int(315532801)
  ["gmmktime(0, 0, 0, 1, 1, 1970)"]=>
  int(0)
  ["strtotime('-10 years', gmmktime(0, 0, 0, 1, 1, 1970))"]=>
  int(-315619200)  <------
  ["strtotime('12/31/1969 19:00:00 -10 years')"]=>
  int(-315619200)
  ["strtotime('+10 years', gmmktime(0, 0, 0, 1, 1, 1965))"]=>
  int(157766400)  <------
  ["strtotime('12/31/1964 19:00:00 +10 years')"]=>
  int(157766400)
}

Actual result:
--------------
array(10) {
  ["mktime(1, 2, 3, 4, 5, 1967)"]=>
  int(-86551077)
  ["strtotime('-10 years', 0)"]=>
  bool(false)  <------
  ["strtotime('-10 years', 1)"]=>
  int(-315619199)
  ["strtotime('+10 years', 0)"]=>
  bool(false)  <------
  ["strtotime('+10 years', 1)"]=>
  int(315532801)
  ["gmmktime(0, 0, 0, 1, 1, 1970)"]=>
  int(0)
  ["strtotime('-10 years', gmmktime(0, 0, 0, 1, 1, 1970))"]=>
  bool(false)  <------
  ["strtotime('12/31/1969 19:00:00 -10 years')"]=>
  int(-315619200)
  ["strtotime('+10 years', gmmktime(0, 0, 0, 1, 1, 1965))"]=>
  bool(false)  <------
  ["strtotime('12/31/1964 19:00:00 +10 years')"]=>
  int(157766400)
}

-- 
Edit bug report at http://bugs.php.net/?id=36638&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36638&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36638&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36638&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36638&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36638&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36638&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36638&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36638&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36638&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36638&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36638&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36638&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36638&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36638&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36638&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36638&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36638&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36638&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36638&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36638&r=mysqlcfg

Reply via email to