Skip to content

Instantly share code, notes, and snippets.

@matsub
Created July 2, 2020 05:21
Show Gist options
  • Save matsub/35e4932c58cbcf87619136116199597c to your computer and use it in GitHub Desktop.
Save matsub/35e4932c58cbcf87619136116199597c to your computer and use it in GitHub Desktop.
<span></span>
<script>
const span = document.querySelector("span");
function step(timestamp) {
const date = new Date();
const d = {
h: date.getHours().toString().padStart(2, '0'),
m: date.getMinutes().toString().padStart(2, '0'),
s: date.getSeconds().toString().padStart(2, '0'),
ms: Math.floor(date.getMilliseconds() / 100),
}
span.textContent = `${d.h}:${d.m}:${d.s}.${d.ms}`;
window.requestAnimationFrame(step);
}
window.requestAnimationFrame(step);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment