js将秒转换为00:00:00时间格式

format(seconds) {
            let hour = Math.floor(seconds / 3600) >= 10 ? Math.floor(seconds / 3600) : '0' + Math.floor(seconds / 3600);
            seconds -= 3600 * hour;
            let min = Math.floor(seconds / 60) >= 10 ? Math.floor(seconds / 60) : '0' + Math.floor(seconds / 60);
            seconds -= 60 * min;
            let sec = seconds >= 10 ? seconds : '0' + seconds;
            return hour + ':' + min + ':' + sec;
        }

 

posted @ 2021-01-25 11:37  问问大将军  阅读(1295)  评论(0编辑  收藏  举报