ID:               35699
 Updated by:       [EMAIL PROTECTED]
 Reported By:      iquito at gmx dot net
-Status:           Assigned
+Status:           Closed
 Bug Type:         Date/time related
 Operating System: Debian Sarge
 PHP Version:      5.1.1
 Assigned To:      derick
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2005-12-20 16:20:55] [EMAIL PROTECTED]

strtotime is actually corrrect here, it's the date() function that is
broken:

<?php
date_default_timezone_set("UTC");
$utc_time1 = strtotime('1964-01-01 00:00:00 UTC');
$utc_time2 = strtotime('1963-12-31 00:00:00 UTC');
echo $utc_time1, ':', $utc_time2, " - ", $utc_time1 - $utc_time2,
"\n";
echo date(DATE_ISO8601, $utc_time1), "\n";
echo date(DATE_ISO8601, $utc_time2), "\n";
?>

-189388800:-189475200 - 86400
1964-01-02T00:00:00+0000
1963-12-31T00:00:00+0000

compare timestamp with date program:
[EMAIL PROTECTED]:~$ date +%s --date "1964-01-01 00:00:00 UTC"
-189388800
[EMAIL PROTECTED]:~$ date +%s --date "1963-12-31 00:00:00 UTC"
-189475200


------------------------------------------------------------------------

[2005-12-16 06:11:58] iquito at gmx dot net

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 this bug report at http://bugs.php.net/?id=35699&edit=1

Reply via email to