<svg width="200" height="200" viewBox="0 0 200 200">
<circle cx="50" cy="50" r="20" fill="rebeccapurple">
<animate
attributeName="cx"
from="50"
to="150"
dur="4s"
repeatCount="indefinite" />
</circle>
</svg>SVGAnimationElement: getCurrentTime() method / notebook
SVGAnimationElement: getCurrentTime() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const animationElement = document.querySelector("animate");
setInterval(() => {
const currentTime = animationElement.getCurrentTime();
console.log(
`Current time relative to the time container: ${currentTime} seconds`,
);
}, 1000);