首页 > 代码库 > javascript将毫秒转换成hh:mm:ss的形式

javascript将毫秒转换成hh:mm:ss的形式

function formatMilliseconds(value) { 	var second = parseInt(value) / 1000;       // second	var minute = 0;                            // minute	var hour = 0;                              // hour	if(second > 60) { 		minute = parseInt(second / 60); 		second = parseInt(second % 60); 		if(minute > 60) { 			hour = parseInt(minute / 60); 			minute = parseInt(minute % 60); 		} 	} 	var result;	if(second >= 10) {		result = "" + parseInt(second); 	}else{		result = "" + "0" + parseInt(second); 	}	if(minute >= 10) { 		result = "" + parseInt(minute) + ":" + result;	}	else{		result = "" + "0" + parseInt(minute) + ":" + result;	}	if(hour >= 10) { 		result = "" + parseInt(hour) + ":" + result; 	}	else{		result = "" + "0" + parseInt(hour) + ":" + result;	}	return result; }