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:
JavaScript
x
4
1
video.ontimeupdate = () => {
2
duration.textContent = video.currentTime
3
}
4
Advertisement
Answer
video.currentTime
outputs the video time in seconds.
You can just convert it to minutes and seconds.
JavaScript
1
5
1
let time = video.currentTime;
2
let minutes = Math.floor(time / 60);
3
let seconds = Math.floor(time - minutes * 60);
4
let timeString = `${minutes}:${seconds}`;
5