Get the current Youtube Video time using JavaScript

Get the current Youtube Video time using JavaScript

In this post we will give you information about Get the current Youtube Video time using JavaScript. Hear we will give you detail about Get the current Youtube Video time using JavaScriptAnd how to use it also give you demo for it if it is necessary.

we are going to learn about how to get the current time of a Youtube Video using JavaScript.

Getting the current time

To get the current time of a Youtube video, first we need to access that element inside the JavaScript using the document.getElementById() method.

const ytvideo = document.getElementById("video-player");

Now, we need to call the getCurrentTime() method on it to get the current time.

ytvideo.getCurrentTime();

Full example:

const ytvideo = document.getElementById("video-player");ytvideo.getCurrentTime();

The getCurrentTime() method returns the elapsed time in seconds since the video started playing.

Note: elapsed time means end time – start time

Hope this code and post will helped you for implement Get the current Youtube Video time using JavaScript. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US