php - PHP - 日期调度
问题描述
你好有没有办法根据输入日期锁定页面。例如管理员输入 2018 年 6 月 18 日开始时间到 2018 年 6 月 22 日结束时间。某些用户功能在开始时间之前被阻止或禁用,并在结束时间再次被禁用。不幸的是,我无法发布代码,因为我不知道该怎么做。很感谢任何形式的帮助
解决方案
您好,一旦解决方案是您需要在 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;
}
}
?>
推荐阅读
- perl - Perl 脚本错误 Can't use an undefined value as a symbol reference at ./sendEvent.pl 第 66 行
- java - 在实例化另一个类时以 ArrayList 的形式传递一个类的对象
- android - 二进制 XML 文件第 28 行:膨胀类 android.widget.TextView 时出错
- python - 将 nop (\x90) 输出到文件
- html - 为什么我的媒体查询不适用于此特定元素?
- python - pygame中的命中检测
- flutter - 如何在flutter中使用Future字符串初始化小部件变量的状态
- javascript - Javascript cdn 资源失败
- c++ - 如何获取多维向量使用的内存
- python - IndexError:列表索引超出范围(在 Reddit 数据爬虫上)