我有一个假期清单,例如:
var holiDays =[[2013,01,01,'New Years Day'],[2013-05-27, 'Memorial Day']]
并在 celender 上显示,但这个列表是硬编码的,所以我想要一个 php 中的函数,以便所有假期列表可见。
$(function() {
$("#id_holiday_date").datepicker({
beforeShowDay: setHoliDays
});
// set holidays function which is configured in beforeShowDay
function setHoliDays(date) {
for (i = 0; i < holiDays.length; i++) {
if (date.getFullYear() == holiDays[i][0]
&& date.getMonth() == holiDays[i][1] - 1
&& date.getDate() == holiDays[i][2]) {
return [true, 'holiday', holiDays[i][3]];
}
}
return [true, ''];
}
});
this function work properly in date picker.this date picker takes date from hardcoded array.
I want a function like that:
function calculateHolidays($year = '') {
$holiDays = Array();
$year = ($year != '') ? $year : date('Y'); //Default Current Year
$newYear = "$year-01-01";
$temp = "$year-05-00 last monday";
$memorialDay = strtotime($temp);//last Monday of May for Current Year
提前致谢