php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42155 checkdate() incorrect behaviour for leap year
Submitted: 2007-07-31 09:40 UTC Modified: 2007-07-31 11:01 UTC
From: ahlers_wim at hotmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.3 OS: All
Private report: No CVE-ID: None
 [2007-07-31 09:40 UTC] ahlers_wim at hotmail dot com
Description:
------------
Dates divisible by 400 should not be a leap year. (for milleniums to come.)
checkdate() should be modified to incorporate this date related cycle.

Reproduce code:
---------------
checkdate(2, 29, 2000);

Expected result:
----------------
FALSE

Actual result:
--------------
TRUE

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-31 11:01 UTC] scottmac@php.net
Years divisible by 400 *are* leap years,
Years divisible by 100 are not leap years
Years divisible by 4 *are* leap years

php -r "var_dump(checkdate(2, 29, 2000));"
bool(true)

php -r "var_dump(checkdate(2, 29, 2100));"
bool(false)

php -r "var_dump(checkdate(2, 29, 2200));"
bool(false)

php -r "var_dump(checkdate(2, 29, 2300));"
bool(false)

php -r "var_dump(checkdate(2, 29, 2400));"
bool(true)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 16:01:29 2024 UTC