PHP检查时间戳大于24小时以后 [英] PHP check if timestamp is greater than 24 hours from now

查看:1038
本文介绍了PHP检查时间戳大于24小时以后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个软件,需要确定截止日期时间是否大于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); 

看看这个CodePad的区别


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆