$pre_day = date("Ymd", $today - 24 * 60 * 60); $next_day = date("Ymd", $today + 24 * 60 * 60); $pre_month = date("Ymd", mktime(0, 0, 0, substr($nowdate, 4, 2) - 1, substr($nowdate, 6, 2), substr($nowdate, 0, 4))); $next_month = date("Ymd", mktime(0, 0, 0, substr($nowdate, 4, 2) + 1, substr($nowdate, 6, 2), substr($nowdate, 0, 4))); $OUT['today'] = date("Y-m-d", $today); $OUT['weekday'] = $LANG_WEEK[date("D", $today)]; $todaybegin = mktime(0, 0, 0, substr($nowdate, 4, 2), substr($nowdate, 6, 2), substr($nowdate, 0, 4)); $todayend = mktime(23, 59, 59, substr($nowdate, 4, 2), substr($nowdate, 6, 2), substr($nowdate, 0, 4)); $weekday_index = array('Sun' => 0, 'Mon' => 1, 'Tue' => 2, 'Wed' => 3, 'Thu' => 4, 'Fri' => 5, 'Sat' => 6); $weekday = $weekday_index[date("D", $today)]; $day = date("j", $today); // wangzi add $logYM = date("Ym", $today); $curDay = date("Ymd"); $preDay = date("Ymd", time() - 24 * 60 * 60); $preDay = getPreWorkingDay($dayArray, $preDay); $fstDay = $weekday_index[date("D", $today - ($day - 1) * 24 * 60 * 60)]; $monthTotalDay = date("t", $today); $out_list = "<TR>\n"; for ($i = 0; $i < $fstDay; $i++) { $out_list .= "\t<TD width=20> </TD>\n"; } for ($i = 1; $i <= $monthTotalDay; $i++) { // wangzi add $logDay = $i; if ($i < 10) { $logDay = '0' . $i; } $logDay = $logYM . $logDay; // wangzi add $isWork = checkIsWorkingDay($dayArray, $logDay);
function getPreWorkingDay($array, $preDay) { foreach ($array as $key => $val) { if ($key == $preDay) { if ($val == 1) { return $preDay; } else { $preDay = date('Ymd', strtotime('-1 day', strtotime($preDay))); return getPreWorkingDay($array, $preDay); } } } return $preDay; }