毫秒转成 00:00:00的时间格式
比如1000毫秒转成00:00:01
/** * 格式化邀请的时间 * @param time ms */ public static formatTime(time:number){ //TODO 计算时、分、秒 //一小时= 1000*60*60 let hour:number = Math.floor(time/(1000*60*60)); //一分钟 = 1000*60 let min:number = Math.floor( (time%(1000*60*60))/(1000*60) ); //一秒 = 1000 let sec:number = Math.floor( (time%(1000*60))/1000 ); let hourStr:string; let minStr:string; let secStr:string; if(hour >=0 && hour <= 9){ hourStr = "0" + hour; }else{ hourStr = hour + ""; } if(min >=0 && min <= 9){ minStr = "0" + min; }else{ minStr = min + ""; } if(sec >=0 && sec <= 9){ secStr = "0" + sec; }else{ secStr = sec + ""; } return hourStr + ":" + minStr + ":" + secStr; }