如果当前时间超过时间X超过30秒(来自数据库) [英] If current time is more than 30 seconds past time X (from the database)
问题描述
我如何构建一个声明,如果当前时间($ time)超过30秒( $ djs ['currenttime']
)?会不会像
How would I construct a statement like if current time ($time) is more than 30 seconds past time ($djs['currenttime']
)? Would it be something like
那样( $ time => $ djs ['currenttime']
)?我无法用30秒来弄明白.. :)。
if ($time => $djs['currenttime']
)? I can't figure it out with the 30 seconds..:).
谢谢:)。
推荐答案
你正在努力的30秒只是在 $的值增加条件时添加
。 +30
djs ['currenttime']
The 30 seconds you are struggling with it's simply a +30
added on the conditional incrementing the value of $djs['currenttime']
.
你可以使用 time()
函数得到实际的时间。我假设 djs ['currenttime']
是从数据库中提取的值。因此,比较如下:
You can use the time()
function to get the actual time. I'm assuming that djs['currenttime']
is a value extracted from the database. Therefore the comparison would be the following:
if(time() > $djs['currenttime'] + 30){
//actions here;
}
time()
返回自1970年1月1日00:00:00 GMT以来的秒数,为此, $ djs ['currenttime']
变量的格式也应该是unix时间戳。如果没有,您需要先将其中一个转换为适当的格式。
time()
returns the number of seconds since Jan 1st 1970 00:00:00 GMT so for this to work, the format of the $djs['currenttime']
variable should also be a unix timestamp. If not, you will need to convert one of them to the appropriate format first.
这篇关于如果当前时间超过时间X超过30秒(来自数据库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!