Skip to content

Instantly share code, notes, and snippets.

@pawelel
Last active October 16, 2021 11:49
Show Gist options
  • Save pawelel/f0f855f5cf944c7fd4dbdf3bad9a60a0 to your computer and use it in GitHub Desktop.
Save pawelel/f0f855f5cf944c7fd4dbdf3bad9a60a0 to your computer and use it in GitHub Desktop.
Simple clock in html with JS
<html lang="en">
<head>
<meta charset="UTF-8">
<title>clock</title>
<script>
function counting() {
"use strict";
var today = new Date(),
day = today.getDay(),
month = today.getMonth() + 1,
year = today.getFullYear(),
hour = today.getHours(),
minute = today.getMinutes(),
second = today.getSeconds();
setTimeout(counting(), 1000);
}
</script>
</head>
<body onload="counting();">
<div id="clock"></div>
<script>
document.getElementById("clock").innerHTML = day+"/"+month+"/"+year+" |"+hour+":"+minute+":"+second;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment