/** * 将秒转化成时:分:秒 * * @param {[Number]} value 秒数 * * @return {[String]} 00:00:00 */ function formatSeconds(value) { if (isNaN(Number(value))) { return 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; } return result; } export default formatSeconds;