js 秒数转时间格式
var a=[193,201,190,126,127,128] for(var i in a){ console.log(i2s(a[i])); } function i2s(ss) { var hh=mm=0; var ss = ~~ss;// 秒 if(ss>3599){ hh=Math.floor(ss/3600); mm=Math.floor(ss%3600/60); ss=ss%60; return (hh>9?hh:'0'+hh)+":"+(mm>9?mm:'0'+mm)+":"+(ss>9?ss:'0'+ss); }else if(ss>59){ mm=Math.floor(ss/60); ss=ss%60; return "00:"+(mm>9?mm:'0'+mm)+":"+(ss>9?ss:'0'+ss); }else{ return "00:00:"+(ss>9?ss:'0'+ss); } }
文章乃参考、转载其他博客所得,仅供自己学习作笔记使用!!!