zoukankan      html  css  js  c++  java
  • PHP 秒数 转时分秒 函数

    function secondsToHour($seconds){
        if(intval($seconds) < 60)
            $tt ="00时00分".sprintf("%02d",intval($seconds%60));
        if(intval($seconds) >=60){
            $h =sprintf("%02d",intval($seconds/60));
            $s =sprintf("%02d",intval($seconds%60));
            if($s == 60){
                $s = sprintf("%02d",0);
                ++$h;
            }
            $t = "00";
            if($h == 60){
                $h = sprintf("%02d",0);
                ++$t;
            }
            if($t){
                $t  = sprintf("%02d",$t);
            }
            $tt= $t."时".$h."分".$s.'秒';
        }
        if(intval($seconds)>=60*60){
            $t= sprintf("%02d",intval($seconds/3600));
            $h =sprintf("%02d",intval($seconds/60)-$t*60);
            $s =sprintf("%02d",intval($seconds%60));
            if($s == 60){
                $s = sprintf("%02d",0);
                ++$h;
            }
            if($h == 60){
                $h = sprintf("%02d",0);
                ++$t;
            }
            if($t){
                $t  = sprintf("%02d",$t);
            }
            $tt= $t."时".$h."分".$s.'秒';
        }
       return  $seconds>0?$tt:'00时00分00秒';
    }
  • 相关阅读:
    有点难度的二分
    请教神牛_字符串hash
    引水进城
    dp的斜率优化
    关于学习oi的一些事项
    永续债
    消费税
    增值税
    BSC交流
    钉钉吐槽功能点
  • 原文地址:https://www.cnblogs.com/wqy415/p/6820538.html
Copyright © 2011-2022 走看看