Php StoreTime和OrderTime处理问题

Php StoreTime和OrderTime处理问题,php,algorithm,Php,Algorithm,假设商店在15:00开门,但客户只能在16:00后下单(取决于商店的开门时间),下面的代码按预期工作 $nowtime = $this->HourMinuteToDecimal(date('H:i')); $OrderTime = $this->HourMinuteToDecimal('16:00'); $storeOpeningTime = $this->HourMinuteToDecimal($data[$key]['op

假设商店在15:00开门,但客户只能在16:00后下单(取决于商店的开门时间),下面的代码按预期工作

        $nowtime = $this->HourMinuteToDecimal(date('H:i'));

        $OrderTime = $this->HourMinuteToDecimal('16:00');

        $storeOpeningTime = $this->HourMinuteToDecimal($data[$key]['opentime']);


        if ($nowtime >= $OrderTime && ($OrderTime >= $storeOpeningTime)) {
            $data[$key]['open'] = 1;
        } else {
            $data[$key]['open'] = 0;
        }


public function HourMinuteToDecimal($hour_minute) {
    $t = explode(':', $hour_minute);
    return $t[0] * 60 + $t[1];
}
有一个问题,如果商店的营业时间是18:00,但默认订单时间是16:00,如何解决这些问题?在这种情况下,客户只能在18:00之后下单


一般规则:客户只能在16:00(订购时间)后下单,但具体取决于店铺的开张时间

订单是在OrderTime和StoreOpeningTime之后进行的,因此这意味着相关时间是这两个时间中最晚的一个

if ($nowtime >= max($OrderTime, $StoreOpeningTime)) {
    $data[$key]['open'] = 1;
}
// ...