Skip to content

Instantly share code, notes, and snippets.

@krschmidt
Last active August 29, 2015 14:02
Show Gist options
  • Save krschmidt/9c71e202ccbb9aa576dd to your computer and use it in GitHub Desktop.
Save krschmidt/9c71e202ccbb9aa576dd to your computer and use it in GitHub Desktop.
Weeks Elapsed + % Elapsed
<html>
<head>
<title>Weeks Elapsed</title>
</head>
<body>
<div id="container" style="width:100%; height:50px; border:1px solid black;">
<div id="progress-bar" style="width:50%;
background-color:black;
height:50px;">
</div>
</div>
<p style="text-align:center;"><span id="progress-percent"></span> of this course is complete!</p>
<p style = "text-align:center;"><span id="weeksElapsed"></span> of <span id="weeksTotal"></span> weeks have passed</p>
<script>
var start = new Date(2014,5,9),
end = new Date(2014,7,2),
today = new Date();
var elapsed = Math.round(((today - start) / (end - start)) * 100) + '%';
document.getElementById("weeksElapsed").innerHTML = Math.round((today - start) / 604800000);
document.getElementById("weeksTotal").innerHTML = Math.round(totalWeeks = (end - start) / 604800000);
document.getElementById("progress-bar").style.width = elapsed;
document.getElementById("progress-percent").innerHTML = elapsed;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment