如果当前时间在当天下午 2 点之前,我需要在 PHP 中进行检查。
我在之前的日期用 strtotime
完成了这个,但是这次它只有一个时间,所以很明显每天 0.00 时间都会重置, bool 值将从 重置false
到 true
。
if (current_time < 2pm) {
// do this
}
最佳答案
if (date('H') < 14) {
$pre2pm = true;
}
有关日期功能的更多信息,请see the PHP manual .我使用了以下时间格式化程序:
H = 24-hour format of an hour (00 to 23)
关于PHP 检查当前时间是否早于指定时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8475019/