1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
timeFormat(time){
let newTime,hour,minite,seconds;
if
(time >= 3600){
hour = parseInt(time/3600) < 10 ?
'0'
+ parseInt(time/3600) : parseInt(time/3600) ;
minite = parseInt(time%60/60) < 10 ?
'0'
+ parseInt(time%60/60):parseInt(time%60/60);
seconds = time%3600 < 10 ?
'0'
+ time%3600 : time%3600;
newTime = hour +
':'
+ minite +
':'
+ seconds;
}
else
if
(time >= 60 && time < 3600){
minite = parseInt(time/60) < 10 ?
'0'
+ parseInt(time/60) : parseInt(time/60);
seconds = time%60 < 10 ?
'0'
+ time%60 : time%60;
newTime = minite +
':'
+ seconds;
}
else
if
(time < 60 ){
seconds = time < 10 ?
'0'
+ time : time;
newTime =
'00:'
+ seconds;
}
return
newTime;
}
|
本文转自 小旭依然 51CTO博客,原文链接:http://blog.51cto.com/xuyran/1966553