判断是否在某个时间段以内

/**
* $datestart 2019-03-30
* $dateend 2019-03-30
* @return int
* 判断是否在某一个时间段以内
*/
protected function get_curr_time_section($datestart,$dateend)
{
$timestart = strtotime($datestart);
$timeend = strtotime($dateend);
//判断是否在指定天数以内
if(time() >= $timestart && time() <= $timeend){
$checkDayStr = date('Y-m-d ',time());
$timeBegin1 = strtotime($checkDayStr."19:00".":00");
$timeEnd1 = strtotime($checkDayStr."23:00".":00");

$curr_time = time();

if($curr_time >= $timeBegin1 && $curr_time <= $timeEnd1)
{
return 1;
}else{
return -1;
}
}else{
return -1;
}
}
posted @ 2019-03-31 17:37  jujusmile  阅读(547)  评论(0编辑  收藏  举报