#35699 [NEW]: strtotime can't handle leap years before 1970

From: Date: Fri, 16 Dec 2005 05:11:59 +0000
Subject: #35699 [NEW]: strtotime can't handle leap years before 1970
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-90518@lists.php.net to get a copy of this message
From:             iquito at gmx dot net
Operating system: Debian Sarge
PHP version:      5.1.1
PHP Bug Type:     Date/time related
Bug description:  strtotime can't handle leap years before 1970

Description:
------------
strtotime() doesn't seem to handle leap years before 1970 correctly, all
dates in a leap year are off by one day when converted by strtotime().

Reproduce code:
---------------
/* shows 1964-06-07 instead of 1964-06-06 */

echo date('Y-m-d', strtotime('1964-06-06'));

/* shows the correct date, 1963-06-06, thus confirming that it has
something to do with leap years, non-leap-years aren't affected. */

echo date('Y-m-d', strtotime('1963-06-06'));

/* curiously, also dates in january and february of a leap year are
affected by this bug */

echo date('Y-m-d', strtotime('1964-01-06')); // returns 1964-01-07

Expected result:
----------------
echo date('Y-m-d', strtotime('1964-06-06')); // should return 1964-06-06 !

Actual result:
--------------
echo date('Y-m-d', strtotime('1964-06-06')); // returns 1964-06-07 !

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


Thread (4 messages)

« previous php.bugs (#90518) next »