-2
我有以下功能拿到2天之间的天数,不包括周末打开返回到变量
function getWorkingDays($startDate, $endDate)
{
$begin = strtotime($startDate);
$end = strtotime($endDate);
if ($begin > $end) {
echo "startdate is in the future! <br />";
return 0;
} else {
$no_days = 0;
$weekends = 0;
while ($begin <= $end) {
$no_days++; // no of days in the given interval
$what_day = date("N", $begin);
if ($what_day > 5) { // 6 and 7 are weekend days
$weekends++;
};
$begin += 86400; // +1 day
};
$working_days = $no_days - $weekends;
return $working_days;
}
}
这工作得很好,但我要如何返回到一个变量来呼应/使用?
$ working_days = getWorkingDays($ start,$ end); –
*你*知道它工作正常吗? –
他可能只是调用函数并在那里回应出结果 –