/** * 判断某个时间戳是否在指定的某一天的某个时间段内 * @param int $timeStamp 需要判断的时间戳 * @param string $type 判断方式,值有:gt lt in * @param string $timeBeginStr 某天的起始时间字符串,如:8:00:00 * @param string $timeEndStr 某天的结束时间字符串,如:21:30:00 * @param string $date 某一天,默认值为当天,如:2021-1-11 * @return bool */ function timeStampIsInPeriod($timeStamp, $type = 'in', $timeBeginStr = '', $timeEndStr = '', $date = '') { !$date && $date = date('Y-m-d'); switch ($type) { case 'gt': if ($timeStamp > strtotime($date . ' ' . $timeBeginStr)) { return true; } break; case 'lt': if ($timeStamp < strtotime($date . ' ' . $timeBeginStr)) { return true; } break; case 'in': if ($timeStamp > strtotime($date . ' ' . $timeBeginStr) && $timeStamp < strtotime($date . ' ' . $timeEndStr)) { return true; } break; } return false; }
—-想了解更多的php相关异常处理怎么解决关注
”
本文来自网络收集,不代表猴子技术宅立场,如涉及侵权请点击右边联系管理员删除。
如若转载,请注明出处:https://www.ssfiction.com/phpjc/546563.html
发表评论电子邮件地址不会被公开。 必填项已用*标注
*昵称:
*邮箱:
网址:
记住昵称、邮箱和网址,下次评论免输入
提交