//将秒转化成时:分:秒
|
function formatSeconds(value) {
|
if(value < 0){
|
value = 0;
|
}
|
var theTime = parseInt(value);// 秒
|
var theTime1 = 0;// 分
|
var theTime2 = 0;// 小时
|
// alert(theTime);
|
if(theTime >= 60) {
|
theTime1 = parseInt(theTime/60);
|
theTime = parseInt(theTime%60);
|
//alert(theTime1+"-"+theTime);
|
if(theTime1 >= 60) {
|
theTime2 = parseInt(theTime1/60);
|
theTime1 = parseInt(theTime1%60);
|
}
|
}
|
var result = (theTime<10?"0":"")+parseInt(theTime);
|
if(theTime1 >= 0) {
|
result =(theTime1<10?"0":"")+parseInt(theTime1)+":"+result;
|
}
|
if(theTime2 >= 0) {
|
result =(theTime2<10?"0":"")+parseInt(theTime2)+":"+result;
|
}
|
//console.info(result);
|
return result;
|
}
|
|
export default formatSeconds;
|