Skip to content

Instantly share code, notes, and snippets.

@mattbk
Created November 8, 2017 16:25
Show Gist options
  • Save mattbk/b32b9a0f867ecb25cb6e9d01ed12efbd to your computer and use it in GitHub Desktop.
Save mattbk/b32b9a0f867ecb25cb6e9d01ed12efbd to your computer and use it in GitHub Desktop.
Double Feature Timer
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: black;
font-family: monospace;
}
</style>
</head>
<body>
<script>
<!--Derived heavily from 'https://www.codingforums.com/javascript-programming/159873-displaying-elapsed-time-post786747.html#post786747' by Old Pedant.-->
start = new Date("October 29, 2017 08:02:45 GMT-05:00");
var seconds = null;
var ticker = null;
function startTimer( )
{
now = new Date()
seconds = now/1000 - start.getTime()/1000
ticker = setInterval("tick( )", 1000);
tick( );
}
function tick( )
{
++seconds;
var secs = seconds;
var hrs = Math.floor( secs / 3600 );
secs %= 3600;
var mns = Math.floor( secs / 60 );
secs %= 60;
var pretty = ( hrs < 10 ? "0" : "" ) + hrs
+ ":" + ( mns < 10 ? "0" : "" ) + mns
+ ":" + ( Math.round(secs) < 10 ? "0" : "" ) + Math.round(secs);
document.getElementById("ELAPSED").innerHTML = pretty;
}
</script>
<body onLoad="startTimer( )">
<div id="ELAPSED" style="font-size:140px; color:white;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment