Skip to content

Instantly share code, notes, and snippets.

@ygweric
Created April 13, 2018 23:39
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 ygweric/d569094ada72739c947ffca0e87e0558 to your computer and use it in GitHub Desktop.
Save ygweric/d569094ada72739c947ffca0e87e0558 to your computer and use it in GitHub Desktop.
Current second and percentage
<!DOCTYPE html>
<html>
<style type="text/css">
.time {}
.percentage {
color: red;
font-size: 5em;
}
</style>
<head>Time - Percentage</head>
<body>
<div>
<span>second:</span>
<label id='time' class='time'></label>
</div>
<span>percentage:</span>
<label id='percentage' class='percentage'></label>
<span>%</span>
</div>
</body>
<script type="text/javascript">
update();
setInterval(update, 1000);
function update() {
var second = new Date().getSeconds();
document.getElementById("time").innerHTML = second;
var percentage = (second/60.0 * 100).toFixed(0);
document.getElementById("percentage").innerHTML = percentage;
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment