note 62792 modified in function.date by danbrown

From: Date: Sun, 20 Jul 2008 02:58:44 +0000
Subject: note 62792 modified in function.date by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142008@lists.php.net to get a copy of this message
The following function will return the date (on the Gregorian calendar) for Orthodox Easter (Pascha). Note that incorrect results will be returned for years less than 1601 or greater than 2399. This is because the Julian calendar (from which the Easter date is calculated) deviates from the Gregorian by one day for each century-year that is NOT a leap-year, i.e. the century is divisible by 4 but not by 10. (In the old Julian reckoning, EVERY 4th year was a leap-year.) This algorithm was first proposed by the mathematician/physicist Gauss. Its complexity derives from the fact that the calculation is based on a combination of solar and lunar calendars. <?php function getOrthodoxEaster($date){ /* Takes any Gregorian date and returns the Gregorian date of Orthodox Easter for that year. */ $year = date("Y", $date); $r1 = $year % 19; $r2 = $year % 4; $r3 = $year % 7; $ra = 19 * $r1 + 16; $r4 = $ra % 30; $rb = 2 * $r2 + 4 * $r3 + 6 * $r4; $r5 = $rb % 7; $rc = $r4 + $r5; //Orthodox Easter for this year will fall $rc days after April 3 return strtotime("3 April $year + $rc days"); } ?> --was-- The following function will return the date (on the Gregorian calendar) for Orthodox Easter (Pascha). Note that incorrect results will be returned for years less than 1601 or greater than 2399. This is because the Julian calendar (from which the Easter date is calculated) deviates from the Gregorian by one day for each century-year that is NOT a leap-year, i.e. the century is divisible by 4 but not by 10. (In the old Julian reckoning, EVERY 4th year was a leap-year.) This algorithm was first proposed by the mathematician/physicist Gauss. Its complexity derives from the fact that the calculation is based on a combination of solar and lunar calendars. <? function getOrthodoxEaster($date){ /* Takes any Gregorian date and returns the Gregorian date of Orthodox Easter for that year. */ $year = date("Y", $date); $r1 = $year % 19; $r2 = $year % 4; $r3 = $year % 7; $ra = 19 * $r1 + 16; $r4 = $ra % 30; $rb = 2 * $r2 + 4 * $r3 + 6 * $r4; $r5 = $rb % 7; $rc = $r4 + $r5; //Orthodox Easter for this year will fall $rc days after April 3 return strtotime("3 April $year + $rc days"); } ?> http://php.net/manual/en/function.date.php

« previous php.notes (#142008) next »