note 39297 deleted from function.date by kennyt

From: Date: Sun, 18 Jul 2004 17:26:02 +0000
Subject: note 39297 deleted from function.date by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73508@lists.php.net to get a copy of this message
Note Submitter: thomas.kaarud@netcom.no ---- I needed a function that could help me find out if any given date was a holiday. The array that contains all holidays add a simple way of making local variations of this function. The function returns True if the given day is a holiday. <? // Input date in format YYYY-MM-DD function check_for_holiday($date) { $year = date('Y',(strtotime($date))); $maundy_thursday = date("Y-m-d",mktime(0,0,0,3,18+easter_days($year),$year)); $good_friday = date("Y-m-d",mktime(0,0,0,3,19+easter_days($year),$year)); $easter_sunday = date("Y-m-d",mktime(0,0,0,3,21+easter_days($year),$year)); $easter_monday = date("Y-m-d",mktime(0,0,0,3,22+easter_days($year),$year)); $ascension_day = date("Y-m-d",mktime(0,0,0,3,60+easter_days($year),$year)); $whit_sunday = date("Y-m-d",mktime(0,0,0,3,70+easter_days($year),$year)); $whit_monday = date("Y-m-d",mktime(0,0,0,3,71+easter_days($year),$year)); $holiday_array = array("$year-01-01", "$year-12-25", $maundy_thursday, $good_friday, $easter_sunday, $easter_monday, $ascension_day, $whit_sunday, $whit_monday ); if (in_array($date, $holiday_array)) return(true); else return(false); } if (check_for_holiday($date)) die("$date is a holiday"); else die("$date is not a holiday"); ?>

« previous php.notes (#73508) next »