Home > Backend Development > PHP Tutorial > php 判断时间大小解决方案

php 判断时间大小解决方案

WBOY
Release: 2016-06-13 10:17:32
Original
1061 people have browsed it

php 判断时间大小
活动结束时间: $gedate=$rs->gedate;
当前时间:$nowdate=date('Y-m-d H:i:s');
  $a=$nowdate - $gedate;
if($a>0){
echo "没有过期";
}elseif($a echo "已经过期";
}else{
  echo "时间一样";
  }
无论你怎么改 ‘$gedate’ 都显示“时间一样”,各位高手,请帮个忙!谢谢!

------解决方案--------------------

PHP code
$a = strtotime('2012-05-10 10:10:10') - time();if($a > 0){    echo '没过期';}else if($a <font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨
我的代码没有问题,你的也没有,只是我写错啦!你能解释一下time()是什么意思吗?是不是和date('Y-m-d H:i:s')一样啊!
Related labels:
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