Skip to content

Instantly share code, notes, and snippets.

@antronic
Last active March 21, 2022 09:59
Show Gist options
  • Save antronic/e9529201bfa8b20153a4bac7287d234a to your computer and use it in GitHub Desktop.
Save antronic/e9529201bfa8b20153a4bac7287d234a to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Just a Clock!</title>
<style type="text/css">
html, body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"
}
</style>
</head>
<body>
<p id="time">Loading...</p>
<script>
// document.body.addEventListener('load', function() {
// setTimeout(window.location.reload(), 1000)
// })
setInterval(function () {
var date = new Date()
var hr = date.getHours()
var min = date.getMinutes()
var sec = date.getSeconds()
function getSep() {
if (sec % 2 === 0) {
return ':'
}
return ' '
}
function leadingZero(n) {
if (n < 10) {
return '0' + n
}
return '' + n
}
var time = `${leadingZero(hr)}${getSep()}${leadingZero(min)}${getSep()}${leadingZero(sec)}`
var pTime = document.querySelector('#time')
pTime.innerText = time
}, 490)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment