我可能有订单的交货日期
$daysOff = ['Sat', 'Sun'];
for ($days = 1; $days <= 7; $days++) {
$day = date("D", strtotime("today + $days day"));
if (!in_array($day, $daysOff)) {
$daysOnRearranged[] = date("D", strtotime("today + $days day"));
}
}
这将显示未来5天的更正
周三,周四,周五,周一,周二
最后一天星期二显示的是今天(第4天),而不是第11天。我该如何解决?
答案 0 :(得分:1)
这是应该做的。您的问题不合适,但已回答。
$daysOff = ['Sat', 'Sun'];
for ($days = 1; $days <= 7; $days++) {
$day = date("D", strtotime("today + $days day"));
$date = date('d', strtotime("today + $days day"));
if (!in_array($day, $daysOff)) {
$daysOnRearranged[$date] = date("D", strtotime("today + $days day"));
}
}
print_r($daysOnRearranged);
答案 1 :(得分:0)
您应该显示如下可用日期:
$daysOff = ['Sat', 'Sun'];
for ($days = 1; $days <= 7; $days++) {
$day = date("D", strtotime("today + $days day"));
if (!in_array($day, $daysOff)) {
$daysOnRearranged[] = date("D, j M", strtotime("today + $days day"));
}
}
print_r($daysOnRearranged);