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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ahlers_wim at hotmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sun Oct 27 16:01:27 2024 UTC