【发布时间】:2020-04-17 12:06:45
【问题描述】:
echo '<select required name="time" id="time" class="time">';
$start = strtotime($this->helper->getOpeningTime());
$end = strtotime($this->helper->getClosingTime());
for ($calltime = $start; $calltime <= $end; $calltime = $calltime + 30 * 60) {
$disabled = '';
$time = date('H:i', $calltime);
$time_with_am_pm = date('g:i a', $calltime);
printf('<option class="time" value="%s" >%s</option>', $time, $time_with_am_pm);
}
echo '</select>';
这是我正在使用的代码和
$start = strtotime($this->helper->getOpeningTime()); - 09:00
$end = strtotime($this->helper->getClosingTime()); - 18:00
我想再添加两个步骤: 假设用户在上午 10 点到达并尝试选择一个时间段,我想禁用上午 10 点到下午 2 点之间的时间,这可能需要禁用吗?
如果当前时间是上午 10 点,我该如何禁用 09:00 和 09:30
期望的输出:
如果用户上午 10 点来,我想提前 4 小时禁用,所以我想禁用 10:30、11:00、11:30、12:00、12:30 13:00、13:30、14 :00 和 14:30
【问题讨论】:
-
试着解释更多关于你想要的输出。您想查看没有 4 小时窗口的所有时间吗? 9.00, 9.30, 10.00, 02.00, .. 06.00?
-
No @AksenP 错了,我想很好,我想尝试展示这个 -> 我想采取两个步骤:如果用户上午 10 点来,我想隐藏过去的时间是 9:00 和 9:30(如果可以或可能的话,必须禁用它)。如果用户上午 10 点来,我想提前 4 小时禁用,所以我想禁用 10:30、11:00、11:30、12:00、12:30 13:00、13:30、14:00 和14:30
标签: php arrays sorting datetime