Skip to content

Instantly share code, notes, and snippets.

@antronic
Last active June 25, 2022 01:02
Show Gist options
  • Save antronic/c6447c350103a16f6a06ce35b71fadf3 to your computer and use it in GitHub Desktop.
Save antronic/c6447c350103a16f6a06ce35b71fadf3 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Progress time</title>
<style type="text/css">
html, body {
margin: 0;
padding: 0;
}
#wrapper {
width: 100%;
height: 5px;
background: #111;
}
#progress {
width: 0%;
height: 100%;
background: #fafafa;
transition: all 1s linear;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="progress"></div>
</div>
<script>
var start = new Date(1647867158177).getTime()
var target = new Date(1647874800000).getTime()
setInterval(function() {
var now = Date.now()
var diff = ((target - now) / (target - start)) * 100
var progressEl = document.querySelector('#progress')
progressEl.style.width = (100 - diff) + '%'
}, 1000)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment