// Set the date we're counting down to
var countDownDate = new Date("Nov 26, 2018 00: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 and 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);
var day = (days < 10) ? "0" + days : days;
var hour = (hours < 10) ? "0" + hours : hours;
var minute = (minutes < 10) ? "0" + minutes : minutes;
var second = (seconds < 10) ? "0" + seconds : seconds;
var x = document.querySelectorAll('.blackfriday');
var i;
for (i = 0; i < x.length; i++) {
x[i].innerHTML = "<div class='black-box'><span class='black-text'>DAYS</span><br><span class='black-number'>" + day + "</span></div><div class='black-box'><span class='black-text'>HOURS</span><br><span class='black-number'>" + hour + " : </span></div><div class='black-box'><span class='black-text'>MINUTES</span><br><span class='black-number'>" + minute + "</span></div><div class='black-box'><span class='black-text'>SECONDS</span><br><span class='black-number'>" + second + "</span></div>";
}
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
var y = document.querySelectorAll('.blackfriday');
var j;
for (j = 0; j < y.length; j++) {
y[j].innerHTML = "EXPIRED";
}
}
}, 1000);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.