插件窝 干货文章 php判断当前时间是否在指定范围时间内

php判断当前时间是否在指定范围时间内

php 829    来源:插件窝    2019-08-22
/**
* @param $start 开始时间
* @param $end 结束时间
* @return int 返回 0 或者 1
* 判断当前时间是否在指定范围时间内
*/
function checkIsBetweenTime($start,$end){
   $date= date('H:i');
   $curTime = strtotime($date);//当前时分
   $assignTime1 = strtotime($start);//获得指定分钟时间戳,00:00
   $assignTime2 = strtotime($end);//获得指定分钟时间戳,01:00
   $result = 0;
   if($curTime>$assignTime1&&$curTime<$assignTime2){
       $result = 1;
   }
   return $result;
}

可以根据自己需要把date的时间格式改成年-日-月 时:分:秒