formatSeconds: function (value) { //毫秒
var secondTime = parseInt(value / 1000);// 秒
var minuteTime = 0;// 分
var hourTime = 0;// 小時(shí)
if (secondTime > 60) {//如果秒數(shù)大于60碎乃,將秒數(shù)轉(zhuǎn)換成整數(shù)
//獲取分鐘动漾,除以60取整數(shù),得到整數(shù)分鐘
minuteTime = parseInt(secondTime / 60);
//獲取秒數(shù)荠锭,秒數(shù)取佘旱眯,得到整數(shù)秒數(shù)
secondTime = parseInt(secondTime % 60);
//如果分鐘大于60,將分鐘轉(zhuǎn)換成小時(shí)
if (minuteTime > 60) {
//獲取小時(shí)证九,獲取分鐘除以60删豺,得到整數(shù)小時(shí)
hourTime = parseInt(minuteTime / 60);
//獲取小時(shí)后取佘的分,獲取分鐘除以60取佘的分
minuteTime = parseInt(minuteTime % 60);
}
}
var result = "" + parseInt(secondTime) + "秒";
if (minuteTime > 0) {
result = "" + parseInt(minuteTime) + "分" + result;
}
if (hourTime > 0) {
result = "" + parseInt(hourTime) + "小時(shí)" + result;
}
return result;
}
毫秒轉(zhuǎn)換 00:00:00
getFormatTime: function (value) {
const str = value / 1000
//獲取小時(shí)值
let timeH = "";
let H = parseInt(str / 3600);
if (H >= 0 && H < 1) {
timeH += "00:";
} else if (H >= 1 && H < 10) {
timeH += "0" + H + ":";
} else {
timeH += H + ":";
}
//獲取分值
let timeM = "";
let M = parseInt(str / 60);
if (M === 0) {
timeM += "00:";
} else if (M > 0 && M < 10) {
timeM += "0" + M + ":";
} else {
timeM += M + ":";
}
var S = parseInt(str % 60);
var timeS = "";
if (S === 0) {
timeS += "00";
} else if (S > 0 && S < 10) {
timeS += "0" + S;
} else {
timeS += S;
}
return timeH + timeM + timeS;
}