我已经在日期之前使用了strtotime,但是这次是在一段时间只有这样,显然每天0.00,时间将重置,布尔值将从 false 重置为 true 。
if(current_time< 2pm){ //这样做 }任何帮助非常感谢!
解决方案if(date('H')< 14){ $ pre2pm = true; }
这是一样容易,因为它匹配。
有关日期功能的更多信息,请查看PHP手册。我使用了以下时间格式化程序:
H =一小时的24小时格式(00到23)
Struggling a bit with this, but sure there's a simple solution. Basically I need to check in PHP if the current time is before 2pm that day.
I've done this with strtotime on dates before, however this time it's with a time only, so obviously at 0.00 each day the time will reset, and the boolean will reset from false to true.
if (current_time < 2pm) { //do this }Any help much appreciated!
解决方案 if (date('H') < 14) { $pre2pm = true; }That is as easy as it gets mate.
For more information about the date function please see the PHP manual. I have used the following time formatter:
H = 24-hour format of an hour (00 to 23)
更多推荐
PHP检查当前时间是否在指定时间之前
发布评论