码迷,mamicode.com
首页 > 其他好文 > 详细

把秒转换成小时:分:秒

时间:2018-09-28 16:43:58      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:===   ring   number   char   fun   str   ==   math   function   

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)) ;
}

把秒转换成小时:分:秒

标签:===   ring   number   char   fun   str   ==   math   function   

原文地址:https://www.cnblogs.com/carry-gan/p/9718923.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!