TypeScript
let toHourMinuteSecondByMillisecond = (millisecond, cfg = {}) => {
let t = "",
ms = Math.round(millisecond),
s = Math.floor(ms / 1000),
d = cfg.isDoubleDigits,//显示双位数
f = cfg.isFourDigits,//显示4位数
hz = cfg.hideZero,//隐藏为0的时间单位
hh = cfg.hideHour,//隐藏小时
hm = cfg.hideMinute,//隐藏分钟
hs = cfg.hideSecond,//隐藏秒钟
hms = cfg.hideMilliSecond;//隐藏毫秒钟
let hour = Math.floor(s / 3600),
min = Math.floor(s / 60) % 60,
sec = s % 60,
msec = ms % 1000;
hh || (hz && !hour) || (d && hour < 10 && (t += "0"), t += hour + ":");
hm || (hz && !min) || (d && min < 10 && (t += "0"), t += min + ":");
hs || (hz && !sec) || (d && sec < 10 && (t += "0"), t += sec);
hms || (hz && !msec) || (f && msec < 1000 && (msec = msec.toString().padStart(3, "0")), t += "." + msec);
return t;
}