PHP检查时间戳大于24小时以后

编程入门 行业动态 更新时间:2024-10-24 17:21:42
本文介绍了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小时以后

本文发布于:2023-10-30 22:52:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544236.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小时   时间   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!