这篇文章主要介绍了如何用PHP制作一个计时器,有一定的参考价值,感兴趣的朋友可以看看, 希望可以帮助到你!
<?php $time=1374465600; if (time()<$time){ echo "false"; }else{ if (time()-$time<60){ $result=time()-$time."秒"; }elseif(time()-$time>=60 && time()-$time<3600){ $min=intval((time()-$time)/60); $sec=(time()-$time)-$min*60; $result=$min."分".$sec."秒"; }elseif(time()-$time>=3600 && time()-$time<86400){ $hour=intval((time()-$time)/3600); $min=intval(((time()-$time)-$hour*3600)/60); $sec=(time()-$time)-$min*60-$hour*3600; $result=$hour."小时".$min."分".$sec."秒"; }elseif(time()-$time>=86400){ $day=intval((time()-$time)/86400); $hour=intval((time()-$time)/3600-$day*24); $min=intval(((time()-$time)-$hour*3600-$day*86400)/60); $sec=(time()-$time)-$min*60-$hour*3600-$day*86400; $result=$day."天".$hour."小时".$min."分".$sec."秒"; } echo $result; } ?>
【相关教程推荐】
2. php从入门到精通
3. bootstrap教程