<video src="livestream.m3u8" controls></video>
<output>Start date: loading…</output>HTMLMediaElement: getStartDate() method / notebook
HTMLMediaElement: getStartDate() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const video = document.querySelector("video");
const display = document.querySelector("output");
video.addEventListener("loadeddata", () => {
const startDate = video.getStartDate();
if (isNaN(startDate.getTime())) {
display.textContent = "Start date: not available";
} else {
display.textContent = `Start date: ${startDate.toLocaleString()}`;
}
});