此函数返回一个包含荷兰国家法定节假日的时间戳数组。解放日(Bevrijdingsdag)每五年(2000 年、2005 年、2010 年...)被添加为国家法定假日。
<?php
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(
mktime(0, 0, 0, 1, 1, $year),
mktime(0, 0, 0, 12, 25, $year),
mktime(0, 0, 0, 12, 26, $year)
);
if (($year % 5) == 0) {
$holidays[] = mktime(0, 0, 0, 5, 5, $year);
}
if ($year <= 2013) { if (date('w', mktime(0, 0, 0, 4, 30, $year)) == 0) { $holidays[] = mktime(0, 0, 0, 4, 29, $year); } else {
$holidays[] = mktime(0, 0, 0, 4, 30, $year); }
} else { if (date('w', mktime(0, 0, 0, 4, 27, $year)) == 0) { $holidays[] = mktime(0, 0, 0, 4, 26, $year); } else {
$holidays[] = mktime(0, 0, 0, 4, 27, $year); }
}
$holidays[] = strtotime('-2 days', mktime(0, 0, 0, $easterMonth, $easterDay, $easterYear));
$holidays[] = mktime(0, 0, 0, $easterMonth, $easterDay, $easterYear);
$holidays[] = strtotime('+1 days', mktime(0, 0, 0, $easterMonth, $easterDay, $easterYear));
$holidays[] = strtotime('+39 days', mktime(0, 0, 0, $easterMonth, $easterDay, $easterYear));
$holidays[] = strtotime('+49 days', mktime(0, 0, 0, $easterMonth, $easterDay, $easterYear));
$holidays[] = strtotime('+50 days', mktime(0, 0, 0, $easterMonth, $easterDay, $easterYear));
sort($holidays);
return $holidays;
}
$holidays = getHolidays(2014);
foreach ($holidays as $holiday) {
echo date('d-M-Y', $holiday) . '<br>';
}
?>