Home > php教程 > php手册 > 如何用PHP制作一个计时器(实例代码)

如何用PHP制作一个计时器(实例代码)

WBOY
Release: 2018-10-25 17:35:15
forward
5392 people have browsed it


这篇文章主要介绍了如何用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;
}
?>
Copy after login

【相关教程推荐】

1. php编程从入门到精通全套视频教程 

2. php从入门到精通  

3. bootstrap教程 

Related labels:
source:cnblogs.com
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template