Home > Backend Development > PHP Tutorial > php 如何判断时间是否大于24小时

php 如何判断时间是否大于24小时

WBOY
Release: 2016-06-23 14:24:07
Original
1744 people have browsed it

数据库的时间 mydate与系统时间比较
如何判断是否大于24小时了?


回复讨论(解决方案)

用时间戳比较
24x3600 

time()+60*60*24

 mydate是什么格式,日期格式吗?用strtotime转换为unix时间轴,然后就参照楼上的方法做就好了,当前时间轴为:time()

$mydate="2013-10-14 09:29:48"; //$mydate="2013-10-10 09:29:48"
$mydate=strtotime($mydate);
echo $mydate."==";
$nowdate=time()+60*60*24;
echo $nowdate;
if($mydate>$nowdate){
echo ">";
}else{
echo " }
?>

为什么两种取值显示出来全是“

$mydate="2013-10-14 09:29:48";
$mydate=strtotime($mydate)+60*60*24;
echo $mydate."==";
$nowdate=time();
echo $nowdate;
if($mydate>$nowdate){
echo ">";
}else{
echo " }
?>
以上的应该是正确的吧

打酱油!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template