I'm trying to get my website to return its video.currentTime value in a minutes:seconds way
For example, this is what I need: 00:10
But I am getting: 10.04
Code:
video.ontimeupdate = () => {
duration.textContent = video.currentTime
}
CodePudding user response:
video.currentTime
outputs the video time in seconds.
You can just convert it to minutes and seconds.
let time = video.currentTime;
let minutes = Math.floor(time / 60);
let seconds = time - minutes * 60;
let timeString = `${minutes}:${seconds}`;