文章标题

两端代码,令人窒息

$hour = date('H'); // 当前时间小时
            $minute = date('i'); //当前时间分钟
            $current_time = $hour * 60 + $minute;

            $open_time = $open_hour * 60 + $open_minute;

            $close_time = $close_hour * 60 + $close_minute;

            $today_time = strtotime(date('Y-m-d', time()));

            if($current_time >= $open_time){
                if($current_time >= $close_time){       /** 如果当前时间 大于 开市时间 且 大于 闭市时间  */
                    if($open_time >=$close_time ){      /** 如果开市时间 大于 闭市时间 那么 专场开市 周期开时间为当前时间,结束时间顺延1天 */
                        $store_status = 0;
                        $cycle_start = time();
                        $cycle_end = $cycle_start + $cycle * 86400 + (($close_hour * 60 + $close_minute) - $current_time) * 60 + 86400;
                    }
                    else{                               /** 如果开市时间 小于 闭市时间 那么 专场闭市 周期开市时间顺顺延1天,结束时间顺延1天 */
                        $cycle_start = $today_time + $open_time * 60 + 86400;
                        $cycle_end = $cycle_start + $cycle * 86400 + (($close_hour * 60 + $close_minute) - ($open_hour * 60 + $open_minute)) * 60 ;
                    }
                }
                else{                                   /** 如果当前时间 大于 开市时间 且 小于 闭市时间 那么专场开市,周期开市时间为当前时间 */
                    $store_status = 1;
                    $cycle_start = time();
                    $cycle_end = $cycle_start + $cycle * 86400 + (($close_hour * 60 + $close_minute) - $current_time) * 60 ;
                }
            }
            else{
                if($current_time >= $close_time){       /** 如果当前时间 小于 开市时间 且 大于 闭市时间 那么专场关闭 ,周期结束时间顺延1天*/
                    $store_status = 0;
                    $cycle_start = $today_time + $open_time * 60;
                    $cycle_end = $cycle_start + $cycle * 86400 + (($close_hour * 60 + $close_minute) - ($open_hour * 60 + $open_minute)) * 60 + 86400;
                }
                else{                                   /** 如果当前时间 小于 开市时间 且 小于 闭市时间 那么专场关闭*/
                    $store_status = 0;
                    if($open_time >=$close_time ){      /** 如果开市时间 大于 闭市时间 那么 周期结束时间顺延1天 */
                        $cycle_start = $today_time + $open_time * 60;
                        $cycle_end = $cycle_start + $cycle * 86400 + (($close_hour * 60 + $close_minute) - ($open_hour * 60 + $open_minute)) * 60 + 86400;
                    }
                    else{                               /** 如果开市时间 小于 闭市时间  周期不顺延 */
                        $cycle_start = $today_time + $open_time * 60;
                        $cycle_end = $cycle_start + $cycle * 86400 + (($close_hour * 60 + $close_minute) - ($open_hour * 60 + $open_minute)) * 60  ;
                    }
                }
            }
$ymd = date('Y-m-d');
            $open_time = strtotime($ymd . ' ' . $open_hour . ':' . $open_minute);
            $close_time = strtotime($ymd . ' ' . $close_hour . ':' . $close_minute);
//            if($open_time)
//            $opeining_time =
            $now_time = time();

            if($now_time >= $open_time && $close_time <= $open_time){
                $store_status = 1;
                $cycle_start = time();
                $cycle_end = $close_time + $cycle * 86400 +86400;
            }
            if($now_time >= $close_time && $open_time <= $close_time){
                $store_status = 0;
                $cycle_start = $open_time + 86400;
                $cycle_end = $close_time + 86400 + $cycle * 86400;
            }
            if($now_time >= $open_time && $now_time <= $close_time){
                $store_status = 1;
                $cycle_start = time();
                $cycle_end = $close_time + $cycle * 86400;
            }
            if($now_time <= $open_time && $now_time >= $close_time){
                $store_status = 0;
                $cycle_start = $open_time + 86400;
                $cycle_end = $close_time + $cycle * 86400 + 86400;
            }
            if($now_time <= $open_time && $open_time <= $close_time){
                $store_status = 0;
                $cycle_start = $open_time;
                $cycle_end = $close_time + $cycle * 86400;
            }
            if($now_time <= $close_time && $close_time <= $open_time){
                $store_status = 1;
                $cycle_start = time();
                $cycle_end = $close_time + $cycle * 86400 + 86400;
            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值