note 18381 added to ref.calendar

From: Date: Sun, 20 Jan 2002 23:42:06 +0000
Subject: note 18381 added to ref.calendar
Groups: php.notes 
Request: Send a blank email to php-notes+get-25582@lists.php.net to get a copy of this message
if, like me, you don't have a PHP build that includes the cal functions, you may want to use this function for sorting out leap year. function days_in_feb($year){ //$year must be YYYY //[gregorian] leap year math : if ($year < 0) $year++; $year += 4800; if ( ($year % 4) == 0) { if (($year % 100) == 0) { if (($year % 400) == 0) { return(29); } else { return(28); } } else { return(29); } } else { return(28); } } of course the next leap year isn't until the end of the century but this makes for timeless code I guess ...or if you are using 2000 in your dates or are going far back in time, etc, it is necessary. -- http://www.php.net/manual/en/ref.calendar.php http://master.php.net/manage/user-notes.php?action=edit+18381 http://master.php.net/manage/user-notes.php?action=delete+18381 http://master.php.net/manage/user-notes.php?action=reject+18381

« previous php.notes (#25582) next »