如果有人选择星期五,我希望它自动将天数添加到星期一。想象一下$leavefrom
2014 年 3 月 1 日是星期四, 2014 年 3 月 2 日$leaveto
是星期五。$totaldays
是根据日期计算的。因此是2天。
<?php
$x = 0;
$date1 = str_replace('-', '/', $leavefrom);
$date2 = str_replace('-', '/', $leaveto);
while ($x < $totaldays) {
$tomorrow = date('l', strtotime($date1 ."+1 days"));
//$tomorrow = date("m-d-Y", strtotime( $date1 ."+1 days" ));
$getday = date('D', strtotime($tomorrow));
$x++;
if ($getday == "Sunday" || $getday = "Saturday") {
$tomorrow = date("m/d/Y", strtotime( $tomorrow ."+1 days" ));
}
$tomorrow = date("m/d/Y", strtotime( $tomorrow ."+1 days" ));
}
echo $tomorrow;
?>