[X]

Digital Clock

time and date 1996 still works

A live ticking clock on the page.

In 2026: Works unchanged.

Where it came from: Netscape JavaScript examples, 1996. MDN

<div id="clock" style="font:bold 20px 'Courier New';color:#00FF00;
     background:#000;display:inline-block;padding:6px 12px;border:2px inset #333">
</div>

<script language="JavaScript">
function tick() {
  var d = new Date();
  var h = d.getHours(), m = d.getMinutes(), s = d.getSeconds();
  var ap = h >= 12 ? "PM" : "AM";
  h = h % 12; if (h === 0) h = 12;
  document.getElementById("clock").innerHTML =
    h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s + " " + ap;
  setTimeout(tick, 1000);
}
tick();
</script>
sandboxed demo · breaks nothing but itselfrestart

More in time and date

all 6 in time and date › · the whole library ›