Hi, ich war ein par Tage in Urlaub - hier eine Lösung
function getEaster(
$iYear = -1
){
// the Golden number
$iGolden= ($iYear % 19) + 1;
// the "Domincal number"
$iDom = ($iYear + (int)($iYear / 4) - (int)($iYear / 100) + (int)($iYear / 400)) % 7;
if ($iDom < 0)
$iDom += 7;
// the solar and lunar corrections
$iSolar = ($iYear - 1600) / 100 - ($iYear - 1600) / 400;
$iLunar = ((($iYear - 1400) / 100) * / 25;
// uncorrected date of the Paschal full moon
$iPFM= (3 - (11 * $iGolden) + $iSolar - $iLunar) % 30;
if ($iPFM < 0) $iPFM += 30;
// corrected date of the Paschal full moon
// days after 21st March
if (($iPFM == 29) || ($iPFM == 28 && $iGolden > 11))
{
$iPFM--;
}
$iTMP= (4 - $iPFM - $iDom) % 7;
if ($iTMP < 0)
$iTMP += 7;
// Easter as the number of days after 21st March */
$iEaster= $iPFM + $iTMP + 1;
if ($iEaster < 11)
{
$iMonth = 3;
$iDay = $iEaster + 21;
}
else
{
$iMonth = 4;
$iDay = $iEaster - 10;
}
$iEaster = mktime(0, 0, 0, $iMonth, $iDay, $iYear, -1);
return $iEaster;
}
//mit dieser Funktion kann man dann die Feiertage bestimmen und z.B. in ein Array schreiben
function getHolidays(
$iYear
){
// Feste Feiertage short / long description
$aHoliday[mktime(0, 0, 0, 1, 1, $iYear)] = 'Neujahr';
$aHoliday[mktime(0, 0, 0, 1, 6, $iYear)] = 'Heilige 3 Könige';
$aHoliday[mktime(0, 0, 0, 5, 1, $iYear)] = '1. Mai';
$aHoliday[mktime(0, 0, 0, 8, 15, $iYear)] = 'Maria Himmelfahrt';
$aHoliday[mktime(0, 0, 0, 10, 3, $iYear)] = 'Tag der deutschen Einheit';
$aHoliday[mktime(0, 0, 0, 10, 31, $iYear)] = 'Reformationstag';
$aHoliday[mktime(0, 0, 0, 11, 1, $iYear)] = 'Allerheiligen';
$aHoliday[mktime(0, 0, 0, 12, 24, $iYear)] = 'Heiligabend';
$aHoliday[mktime(0, 0, 0, 12, 25, $iYear)] = '1. Weihnachtsfeiertag';
$aHoliday[mktime(0, 0, 0, 12, 26, $iYear)] = '2. Weihnachtsfeiertag';
$aHoliday[mktime(0, 0, 0, 12, 31, $iYear)] = 'Sylvester';
// Bewegliche Feiertage, von Ostern abhängig
$iEaster = getEaster($iYear);
$iEasterDay = date('d',$iEaster);
$iEasterMonth = date('m',$iEaster);
$iEasterYear = date('Y',$iEaster);
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay-48,$iEasterYear)]= 'Rosenmontag';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay-46,$iEasterYear)]= 'Aschermittwoch';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay-2,$iEasterYear)] = 'Karfreitag';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay,$iEasterYear)] = 'Ostersonntag';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay+1,$iEasterYear)] = 'Ostermontag';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay+39,$iEasterYear)]= 'Himmelfahrt';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay+49,$iEasterYear)]= 'Pfingstsonntag';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay+50,$iEasterYear)]= 'Pfingstmontag';
$aHoliday[mktime(0,0,0,$iEasterMonth,$iEasterDay+60,$iEasterYear)]= 'Fronleichnam';
// Bewegliche Feiertage, vom ersten Advent abhängig
$iFirstAdvent = getFirstAdvent($iYear);
$iAdventDay = date('d',$iFirstAdvent);
$iAdventMonth = date('m',$iFirstAdvent);
$iAdventYear = date('Y',$iFirstAdvent);
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay,$iAdventYear)]= '1. Advent';
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay+7,$iAdventYear)]= '2. Advent';
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay+14,$iAdventYear)]= '3. Advent';
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay+21,$iAdventYear)]= '4. Advent';
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay-32,$iAdventYear)]= 'Buß- und Bettag';
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay-28,$iAdventYear)]= 'Totensonntag';
$aHoliday[mktime(0,0,0,$iAdventMonth,$iAdventDay-35,$iAdventYear)]= 'Volkstrauertag';
return $aHoliday;
}
function getFirstAdvent(
$iYear
){
$iFirstAdvent = mktime(0, 0, 0, 11, 26, $iYear);
while (0 != date('w', $iFirstAdvent))
$iFirstAdvent += 86400;
return $iFirstAdvent;
}//getFirstAdvent()...
//und hier noch was um andere 'wichtige' Tage zu berechnen
function getImportantDays(
$iYear
){
// summertime
for($i=31;$i<=40;$i--) {
if(date ("w", mktime(0,0,0,3,$i,$iYear)) == "0")
{
$iSummertime = mktime(0,0,0,3,$i,$iYear);
break;
}
}
// wintertime
for($i=30;$i<=40;$i--) {
if(date ("w", mktime(0,0,0,10,$i,date("Y"))) == "0")
{
$iWintertime = mktime(0,0,0,10,$i,date("Y"));
break;
}
}
// mothersday
$l=0;
for($i=0;$i<=31;$i++) {
if(date ("w", mktime(0,0,0,5,$i,date("Y"))) == "0")
$l++;
if($l==2)
{
$iMothersday = mktime(0,0,0,5,$i,date("Y"));
break;
}
}
$aImportantDays[mktime(0,0,0,1,1+44,$iYear)] = 'Valentienstag';
$aImportantDays[mktime(0,0,0,1,1+79+date("L"),$iYear)] = 'Frühlingsanfang';
$aImportantDays[mktime(0,0,0,1,1+171+date("L"),$iYear)] = 'Sommeranfang';
$aImportantDays[mktime(0,0,0,1,1+275+date("L"),$iYear)] = 'Herbstanfang';
$aImportantDays[mktime(0,0,0,1,1+355+date("L"),$iYear)] = 'Winteranfang';
$aImportantDays[$iSummertime] = 'Sommerzeitumstellung';
$aImportantDays[$iWintertime] = 'Winterzeitumstellung';
$aImportantDays[$iMothersday] = 'Muttertag';
return $aImportantDays;
}
$aDays = getHolidays(date('Y'));
//$aDays2 = getImportantDays(date('Y'));
print_r($aDays);
echo 'heute ist der : '. date('d.m.y');
if(array_key_exists(strtotime(date('Y-m-d')), $aDays))
echo " - es ist ". $aDays[strtotime(date('Y-m-d'))];
?>