PHP检查时间戳大于24小时以后 [英] PHP check if timestamp is greater than 24 hours from now
本文介绍了PHP检查时间戳大于24小时以后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ date = strtotime(2013-07-13)+ strtotime 05:30:00);
if($ date> time()+ 86400){
echo'yes';
} else {
echo'no';
}
我目前的日期和时间是2013-07-13 2am。你可以看到它只有3个小时的路程。
在我的数学上,这是10800秒。我的功能是返回是
。对我来说,这就是说,$ code> $ date 大于现在加上86400秒,其实它只有10800秒。不应该返回否
?
解决方案
$ date = strtotime(2013-07-13)+ strtotime(05:30:00);
应该是
code> $ date = strtotime(2013-07-13 05:30:00);
I have software that needs to determine if the cutoff datetime is greater than 24 hours from now. Here is the code I have to test that.
$date = strtotime("2013-07-13") + strtotime("05:30:00");
if($date > time() + 86400) {
echo 'yes';
} else {
echo 'no';
}
My current date and time is 2013-07-13 2am. As you can see its only 3 hours away.
At my math thats 10800 seconds away. The function I have is returning yes
. To me this is saying the $date
is greater than now plus 86400 seconds when in fact its only 10800 seconds away. Should this not be returning no
?
解决方案
$date = strtotime("2013-07-13") + strtotime("05:30:00");
should be
$date = strtotime("2013-07-13 05:30:00");
See difference in this CodePad
这篇关于PHP检查时间戳大于24小时以后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文