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; }
javascript将毫秒转换成hh:mm:ss的形式
时间: 2024-10-11 21:53:58