js时间毫秒转换为字符串时分秒
程序员文章站
2024-01-28 09:17:04
...
convertTimeFormat(timems) {
let str = '';
const time = parseInt(timems);
const hour = Math.floor(time / 3600);
const hourFormat = hour > 9 ? hour : ('0' + hour);
const minute = Math.floor((time - hour * 3600) / 60);
const minuteFormat = minute > 9 ? minute : ('0' + minute);
const second = Math.floor((time - hour * 3600) - minute * 60);
const secondFormat = second > 9 ? second : ('0' + second);
str += hourFormat + ":" + minuteFormat + ":" + secondFormat;
return str;
}
上一篇: js基础部分(1)
下一篇: AsyncTask异步任务类