首页 > 解决方案 > PHP - 日期调度

问题描述

你好有没有办法根据输入日期锁定页面。例如管理员输入 2018 年 6 月 18 日开始时间到 2018 年 6 月 22 日结束时间。某些用户功能在开始时间之前被阻止或禁用,并在结束时间再次被禁用。不幸的是,我无法发布代码,因为我不知道该怎么做。很感谢任何形式的帮助

标签: phpdateinputtimer

解决方案


您好,一旦解决方案是您需要在 php.ini 和 disabled_function 中更改它,但这对于用户定义的函数没有意义,并且也无法在运行时更改,所以我希望您更喜欢替代解决方案是

<?php
    $startTime   = strtotime('2008-09-22');
    $endTime     = strtotime('2008-09-25');
    $now = new DateTime();
    $currentDate = $now->format('Y-m-d');
    $currentTime = $now->getTimestamp(); 

    function a(){
     if($currentTime>$startTime && $currentTime<$endTime){
       // in this scope this is enable so you can put logic here
     } else {
       // in this scope this is disable section so you can return error warning and false
        return false;
     }
    }
?>

推荐阅读