秒转时分秒

function formatSeconds(value) {
var theTime = parseInt(value);// 秒
var theTime1 = 0;// 分
var theTime2 = 0;// 小时
if(theTime > 60) {
theTime1 = parseInt(theTime/60);
theTime = parseInt(theTime%60);
if(theTime1 > 60) {
theTime2 = parseInt(theTime1/60);
theTime1 = parseInt(theTime1%60);
}
}
if(theTime1<=9){
theTime1 = "0" + theTime1
}
if(theTime2<=9){
theTime2 = "0" + theTime2
}
if(theTime<=9){
theTime = "0" + theTime
}
result = theTime2+":"+theTime1+":"+theTime;
return result;
}
posted @ 2019-05-13 14:42  诺克萨斯小刀  阅读(178)  评论(0编辑  收藏  举报