note 17374 deleted from function.date by jimw

From: Date: Thu, 20 Dec 2001 21:28:36 +0000
Subject: note 17374 deleted from function.date by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23450@lists.php.net to get a copy of this message
For people who don't have the "Calendar" library compiled in PHP. Here is the source code of the function easter() which calculates all relevant information about the easter sunday of a given year. Have fun <? function easter($y) { $a = $y%19; $b = intval($y/100); $c = $y%100; $d = intval($b/4); $e = $b%4; $f = intval(($b+8)/25); $g = intval(($b-$f+1)/3); $h = (19*$a+$b-$d-$g+15)%30; $i = intval($c/4); $k = $c%4; $l = (32+2*$e+2*$i-$h-$k)%7; $m = intval(($a+11*$h+22*$l)/451); $p = ($h+$l-7*$m+114)%31; $EasterMonth = intval(($h+$l-7*$m+114)/31); // [3 = March, 4 = April] $EasterDay = $p+1; // (day in Easter Month) return array( "day" => $EasterDay, "month" => $EasterMonth, "year" => $y, "timestamp" => mktime(0,0,0, $EasterMonth, $EasterDay, $y), "day_of_year" => date("z", mktime(0,0,0, $EasterMonth, $EasterDay, $y)) ); } ?>

« previous php.notes (#23450) next »