note 70654 rejected from function.date by betz

From: Date: Wed, 25 Oct 2006 15:32:36 +0000
Subject: note 70654 rejected from function.date by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-119109@lists.php.net to get a copy of this message
Note Submitter: will at willjw dot co dot uk ---- If you need to work out when Mothering Sunday (UK) is for a given a year, this will do the job. But for some reason (suggestions welcome) it will only work for years between 1902 and 2037. <?php function mothering_sunday($year) { $easter = array("3/27", "4/14", "4/3", "3/23", "4/11", "3/31", "4/18", "4/8", "3/28", "4/16", "4/5", "3/25", "4/13", "4/2", "3/22", "4/10", "3/30", "4/17", "4/7"); $remainder = fmod(($year + 1), 19); list($month, $date) = explode("/", $easter[$remainder]); $day = date("N", mktime(0, 0, 0, $month, $date, $year)); $mothering_sunday = date("d/m/Y", mktime(0, 0, 0, $month, (($date + (7 - $day)) - 21), $year)); return $mothering_sunday; } ?>

« previous php.notes (#119109) next »