I found this countdown clock in CodePen, but I need to edit it, I need to set the final date to May 30, 2024. ¿Does anybody know how to set up the final date?
document.addEventListener('DOMContentLoaded', () => {
// Unix timestamp (in seconds) to count down to
var twoDaysFromNow = (new Date().getTime() / 1000) + (86400 * 2) + 1;
// Set up FlipDown
var flipdown = new FlipDown(twoDaysFromNow)
// Start the countdown
.start()
// Do something when the countdown ends
.ifEnded(() => {
console.log('The countdown has ended!');
});
// Toggle theme
var interval = setInterval(() => {
let body = document.body;
body.classList.toggle('light-theme');
body.querySelector('#flipdown').classList.toggle('flipdown__theme-dark');
body.querySelector('#flipdown').classList.toggle('flipdown__theme-light');
}, 5000);
var ver = document.getElementById('ver');
ver.innerHTML = flipdown.version;
});
Or anybody can tell me where ¿I can find a flip countdown easy to set up?
THANKS
2
Answers
Get the
timestamp
with milliseconds ofMay 30, 2024
, then turn it to seconds by dividing by1000
, and pass it to theFlipDown
constructor86400 * 2
is meant to be 2 days in secondsso one day is
(24 * 60 * 60 = 86400)
and 2 days is
(2 * 86400)
review the docs