我最近需要编写一个函数,让我知道今天是否是节假日。
在法国,我们有一些取决于复活节日期的节假日。也许这对某人会有用。
只需在 $holidays 数组中修改您国家/地区的实际节假日日期。
<?php
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(
mktime(0, 0, 0, 1, 1, $year), mktime(0, 0, 0, 5, 1, $year), mktime(0, 0, 0, 5, 8, $year), mktime(0, 0, 0, 7, 14, $year), mktime(0, 0, 0, 8, 15, $year), mktime(0, 0, 0, 11, 1, $year), mktime(0, 0, 0, 11, 11, $year), mktime(0, 0, 0, 12, 25, $year), 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;
}
?>