note 92452 deleted from function.checkdate by danbrown
| From: | danbrown@php.net | Date: | Wed, 30 Mar 2011 14:03:36 +0000 |
| Subject: | note 92452 deleted from function.checkdate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-178340@lists.php.net to get a copy of this message | ||
Note Submitter: gman at gmail dot com
----
Advanced Leap year function
<?php
function is_leap($year = null)
{
switch ($year) {
case strpos('+', $year):
$chunk = explode('+', $year);
return checkdate(2, 29, date('Y') + (int)$chunk[1]);
break;
default:
return checkdate(2, 29, ($year == null) ? date('Y') : (int)$year);
}
}
//Usage
if (is_leap()) {
echo "Current Year is a leap year";
}
if (is_leap(1992)) {
"1992 was a leap year";
}
if (is_leap( + 4)) {
"In four years it will be a leap year";
}
?>