• php时间段判断


    <?php
    function times(){
        
        ini_set('date.timezone','Asia/Shanghai');
        
        $time = date("Y-m-d H:i");
        
        /*5.1*/
        if($time>"2017-05-01 09:00" && $time<"2017-05-01 09:20"){
            return "in";
        }
        if($time>"2017-05-01 10:00" && $time<"2017-05-01 10:20"){
            return "in";
        }
        if($time>"2017-05-01 11:00" && $time<"2017-05-01 11:20"){
            return "in";
        }
        if($time>"2017-05-01 15:00" && $time<"2017-05-01 15:20"){
            return "in";
        }
        if($time>"2017-05-01 16:00" && $time<"2017-05-01 16:20"){
            return "in";
        }
        if($time>"2017-05-01 17:00" && $time<"2017-05-01 17:20"){
            return "in";
        }
        
        /*5.2*/
        if($time>"2017-05-02 09:00" && $time<"2017-05-02 09:20"){
            return "in";
        }
        if($time>"2017-05-02 10:00" && $time<"2017-05-02 10:20"){
            return "in";
        }
        if($time>"2017-05-02 11:00" && $time<"2017-05-02 11:20"){
            return "in";
        }
        if($time>"2017-05-02 15:00" && $time<"2017-05-02 15:20"){
            return "in";
        }
        if($time>"2017-05-02 16:00" && $time<"2017-05-02 16:20"){
            return "in";
        }
        if($time>"2017-05-02 17:00" && $time<"2017-05-02 17:20"){
            return "in";
        }
        
        /*5.3*/
        if($time>"2017-05-03 09:00" && $time<"2017-05-03 09:20"){
            return "in";
        }
        if($time>"2017-05-03 10:00" && $time<"2017-05-03 10:20"){
            return "in";
        }
        if($time>"2017-05-03 11:00" && $time<"2017-05-03 11:20"){
            return "in";
        }
        if($time>"2017-05-03 15:00" && $time<"2017-05-03 15:20"){
            return "in";
        }
        if($time>"2017-05-03 16:00" && $time<"2017-05-03 16:20"){
            return "in";
        }
        if($time>"2017-05-03 17:00" && $time<"2017-05-03 17:20"){
            return "in";
        }
        
        return "noin";
        
    }
    ?>
  • 相关阅读:
    python Exception中的raise、assert
    python循环语句与其他编程语言不同之处
    【转】最大似然估计
    尝试发表代码
    奇异分解(SVD)
    Python学习笔记3-string
    梯度下降法
    前后端分离
    Trie树
    HashMap的工作原理以及代码实现,为什么要转换成红黑树?
  • 原文地址:https://www.cnblogs.com/hellowzd/p/6757801.html
Copyright © 2020-2023  润新知