Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save loeasy68/36747ead14f74ca242c436dc1853ba5c to your computer and use it in GitHub Desktop.
Save loeasy68/36747ead14f74ca242c436dc1853ba5c to your computer and use it in GitHub Desktop.
Countdown script - Bad Samaritan (LIVE Embed)
<link href="https://fonts.googleapis.com/css?family=Yantramanav:400,500,700,900" rel="stylesheet">
<!-- Display the countdown timer in an element -->
<p id="demo" style="background-image: -moz-linear-gradient(top,#b8b0af 0%,#f2ecea 100%);
background-image: -webkit-linear-gradient(top,#b8b0af 0%,#f2ecea 100%);
background-image: -o-linear-gradient(top,#b8b0af 0%,#f2ecea 100%);
background-image: -ms-linear-gradient(top,#b8b0af 0%,#f2ecea 100%);
background-image: linear-gradient(top,#b8b0af 0%,#f2ecea 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
position:relative;font-size:1.2em;font-family: 'Yantramanav', sans-serif;font-weight:900;text-align: center;"></p>
// Set the date we're counting down to
var countDownDate = new Date("May 5, 2019 12:00:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment