note 92485 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Mon, 27 Jul 2009 03:20:16 +0000 |
| Subject: | note 92485 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158756@lists.php.net to get a copy of this message | ||
Note Submitter: glenm
----
@seanj : Your logic isn't quite right.
A year is a leap year if it's divisible by 4 unless it's also divisible by 100 in which
case it needs to be divisible by 400 to be a leap year.
1900: not a leap year
2000: a leap year
2100: not a leap year
2200: not a leap year
2300: not a leap year
2400: a leap year
The full logic if not using the date function would be something like this:
function is_leap($year)
{
return ($year%400 == 0) || ($year%4 == 0 && $year%100 != 0);
}
(I'm not sure why a default of 2004 was included in the previous examples as that makes no
sense at all to me.)