// Get the current date
let today = new Date();
today = new Date(today);
// Set the target date to October 2nd at 11:59 PM CET in Vienna timezone
let targetDate = new Date('2024-10-03T13:59:00+02:00');
targetDate = new Date(targetDate);
// Calculate the time difference in milliseconds
let timeDifference = targetDate - today;
// Convert the time difference from milliseconds to days
let daysLeft = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
document.getElementById('alert__date-days-number').textContent = `${daysLeft}`;
let hoursLeft = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutesLeft = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60));
console.log(today);
console.log(daysLeft, hoursLeft, minutesLeft);
if (daysLeft < 0) {
document.getElementById('alert__date-days-number').textContent = '0';
document.getElementById('alert__date-days').textContent = 'Days';
} else if (daysLeft < 3) {
document.getElementById('alert__date-days-number').textContent = `${hoursLeft}:${minutesLeft}`;
document.getElementById('alert__date-days').textContent = 'h';
} else if (daysLeft <= 2) {
document.getElementById('alert__date-days').textContent = 'Tage';
} else {
document.getElementById('alert__date-days-number').textContent = `${daysLeft}`;
}
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.