Skip to content

Instantly share code, notes, and snippets.

@peerasan
Created January 22, 2021 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peerasan/6c2fb30102bddbc235e74bdb5dd7ad8e to your computer and use it in GitHub Desktop.
Save peerasan/6c2fb30102bddbc235e74bdb5dd7ad8e to your computer and use it in GitHub Desktop.
OBS - display milliseconds time
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--
modidfy from https://codepen.io/jasonleewilson/pen/gPrxwX
-->
<head>
<title>OBS - show time milliseconds</title>
<script>
// START CLOCK SCRIPT
Number.prototype.pad = function (n) {
for (var r = this.toString(); r.length < n; r = 0 + r);
return r;
};
function updateClock() {
var now = new Date();
var milli = now.getMilliseconds(),
sec = now.getSeconds(),
min = now.getMinutes(),
hou = now.getHours(),
mo = now.getMonth(),
dy = now.getDate(),
yr = now.getFullYear();
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var tags = ["mon", "d", "y", "h", "m", "s", "mi"],
corr = [months[mo], dy, yr, hou.pad(2), min.pad(2), sec.pad(2), milli];
for (var i = 0; i < tags.length; i++)
document.getElementById(tags[i]).firstChild.nodeValue = corr[i];
}
function initClock() {
updateClock();
window.setInterval("updateClock()", 1);
}
</script>
<style>
body {
background-color: #2d2d2d;
}
#timedate {
font: small-caps lighter 10rem "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
text-align: left;
width: 100%;
color: #fff;
/* padding: 20px;
margin: 0 auto; */
}
</style>
</head>
<body onLoad="initClock()">
<div id="timedate">
<a id="mon">January</a>
<a id="d">1</a>,
<a id="y">0</a><br />
<a id="h">12</a>:
<a id="m">00</a>:
<a id="s">00</a>:
<a id="mi">000</a>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment