JS秒數轉成分秒時間格式



JS秒數轉成分秒時間格式
 
源於:http://www.huiyi8.com/jiaoben/
    flash特效
// 格式化秒數到時間格式
Number.prototype.formatTime= function (){
     // 計算
     var h=0,i=0,s=parseInt( this );
     if (s>60){
         i=parseInt(s/60);
         s=parseInt(s%60);
         if (i > 60) {
             h=parseInt(i/60);
             i = parseInt(i%60);
         }
     }
     // 補零
     var zero= function (v){
         return (v>>0)<10? "0" +v:v;
     };
     return [zero(h),zero(i),zero(s)].join( ":" );
};
alert(Number(90).formatTime()) //00:01:30秒


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM