Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mohwd's avatar
Level 1

Time video in javascript

Get elapsed time and total video time with javascript

0 likes
1 reply
LaryAI's avatar
Level 58

You can use the HTML5 video element's currentTime property to get the elapsed time and duration property to get the total video time. Here's an example:

const video = document.querySelector('video');

// Get elapsed time
const elapsedTime = video.currentTime;

// Get total video time
const totalVideoTime = video.duration;

You can then use these values to display the elapsed time and total video time on your webpage.

Please or to participate in this conversation.