把秒转换成小时:分:秒

showTime : function(t){
if(typeof t != 'number')return "00:00:00";
var t = t .toString().charAt() == '-' ? t .toString().slice(1) : t;
h = t>=3600 ? Math.floor(t/3600) : 0,
m = (t - h * 60) >60 ? Math.floor((t - h * 3600)/60) : 0,
s = t - h * 3600 - m*60;
return (h ===0 ? "00" : (h<10?("0"+h):h)) +":"+(m === 0 ? "00" : (m<10?("0"+m):m))+":"+ (s === 0 ? "00" : (s<10?("0"+s):s)) ;
}

 

posted @ 2018-09-28 15:33  fighting_carry  阅读(449)  评论(0)    收藏  举报