Last active
June 26, 2017 18:15
-
-
Save shahid249/cbba4da442b0586734bc072f9c2f0f58 to your computer and use it in GitHub Desktop.
This code show cowntdown timer clock - JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This display the countdown timer clock in an element --> | |
<p id="timer"></p> | |
<script> | |
//Put here the time and date when it will stop ("Sep 17, 2020 15:37:25") | |
var countdowndate = new Date("Sep 17, 2020 15:37:25").getTime(); | |
var x = setInterval(function() { | |
var now = new Date().getTime(); | |
var timecal = countdowndate - now; | |
var days = Math.floor(timecal/(1000*60*60*24)); | |
var hours = Math.floor((timecal%(1000*60*60*24))/(1000*60*60)); | |
var minutes = Math.floor((timecal%(1000 * 60 * 60))/(1000 * 60)); | |
var seconds = Math.floor((timecal%(1000*60))/1000); | |
document.getElementById("timer").innerHTML = days + "d " + hours + "h " | |
+ minutes + "m " + seconds + "s "; | |
if (timecal<0) {clearInterval(x);document.getElementById("timer").innerHTML = "expire";}},1000); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment