note 70654 added to function.date
| From: | will at willjw dot co dot uk | Date: | Mon, 23 Oct 2006 11:57:51 +0000 |
| Subject: | note 70654 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119000@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 172.189.237.213
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/70654
Del: integrated -- https://master.php.net/note/delete/70654/integrated
Del: useless -- https://master.php.net/note/delete/70654/useless
Del: bad code -- https://master.php.net/note/delete/70654/bad+code
Del: spam -- https://master.php.net/note/delete/70654/spam
Del: non-english -- https://master.php.net/note/delete/70654/non-english
Del: in docs -- https://master.php.net/note/delete/70654/in+docs
Del: other reasons-- https://master.php.net/note/delete/70654
Reject -- https://master.php.net/note/reject/70654
Search -- https://master.php.net/manage/user-notes.php