PHP runs once a year. It must be specified for each configuration. The current year, statutory holidays, and days off are unavailable? Php $ year2014; functionaddYear ($ date) {return $ GLOBALS [year]. -. $ date;} functiongetWorkDays ($ startDate, $ endDate, $ publicHolidays, $ holidayTune) {$ workDaysarray (); whi
PHP runs once a year. It must be specified for each configuration. The current year, statutory holidays, and days off are unavailable? Php $ year = '20140901'; function addYear ($ date) {return $ GLOBALS ['Year']. '-'. $ date;} function getWorkDays ($ startDate, $ endDate, $ publicHolidays, $ holidayTune) {$ workDays = array (); whi
PHP runs once a year. It must be specified for each configuration. The current year, statutory holidays, and days off. <无>
=$endDate){break;} } foreach($workDays as $k=>$date) { $info = getdate(strtotime($date)); if(in_array($info['weekday'],array('Sunday','Saturday')) and !in_array($date,$holidayTune)) { unset($workDays[$k]); } } return $workDays;}// define the public holidays$publicHolidays = array('1-1','1-31','2-1','2-2','2-3','2-4','2-5','2-6','4-5','4-6','4-7','5-1','5-2','5-3','5-31','6-1','6-2','9-6','9-7','9-8','10-1','10-2','10-3','10-4','10-5','10-6','10-7');$publicHolidays = array_map('addYear',$publicHolidays);// define the holiday tune.$holidayTune = array('1-26','2-8','5-4','9-28','10-11');$holidayTune = array_map('addYear',$holidayTune);// initialize starting date and the ending date.$startDate = strtotime($year.'-1-1');$endDate = strtotime('+1 Year', $startDate);$workDays = getWorkDays($startDate,$endDate,$publicHolidays,$holidayTune);echo json_encode($workDays);