note 96686 added to function.easter-date

From: Date: Thu, 11 Mar 2010 15:44:45 +0000
Subject: note 96686 added to function.easter-date
Groups: php.notes 
Request: Send a blank email to php-notes+get-166915@lists.php.net to get a copy of this message
I recently had to write a function that allows me to know if today is a holiday. And in France, we have some holidays which depends on the easter date. Maybe this will be helpful to someone. Just modify in the $holidays array the actual holidays dates of your country. <?php /** * This function returns an array of timestamp corresponding to french holidays */ protected static function getHolidays($year = null) { if ($year === null) { $year = intval(date('Y')); } $easterDate = easter_date($year); $easterDay = date('j', $easterDate); $easterMonth = date('n', $easterDate); $easterYear = date('Y', $easterDate); $holidays = array( // These days have a fixed date mktime(0, 0, 0, 1, 1, $year), // 1er janvier mktime(0, 0, 0, 5, 1, $year), // Fête du travail mktime(0, 0, 0, 5, 8, $year), // Victoire des alliés mktime(0, 0, 0, 7, 14, $year), // Fête nationale mktime(0, 0, 0, 8, 15, $year), // Assomption mktime(0, 0, 0, 11, 1, $year), // Toussaint mktime(0, 0, 0, 11, 11, $year), // Armistice mktime(0, 0, 0, 12, 25, $year), // Noel // These days have a date depending on easter mktime(0, 0, 0, $easterMonth, $easterDay + 2, $easterYear), mktime(0, 0, 0, $easterMonth, $easterDay + 40, $easterYear), mktime(0, 0, 0, $easterMonth, $easterDay + 50, $easterYear), ); sort($holidays); return $holidays; } ?> ---- Server IP: 195.221.21.36 Probable Submitter: 80.14.60.179 ---- Manual Page -- http://www.php.net/manual/en/function.easter-date.php Edit -- https://master.php.net/note/edit/96686 Del: integrated -- https://master.php.net/note/delete/96686/integrated Del: useless -- https://master.php.net/note/delete/96686/useless Del: bad code -- https://master.php.net/note/delete/96686/bad+code Del: spam -- https://master.php.net/note/delete/96686/spam Del: non-english -- https://master.php.net/note/delete/96686/non-english Del: in docs -- https://master.php.net/note/delete/96686/in+docs Del: other reasons-- https://master.php.net/note/delete/96686 Reject -- https://master.php.net/note/reject/96686 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166915) next »