我在CodePen中找到了这个倒计时时钟,但我需要编辑它,我需要将最终日期设置为2024年5月30日。¿有谁知道如何设置最终日期?
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;
});
或者任何人都可以告诉我在哪里可以找到易于设置的翻转倒计时?
谢谢
获取
timestamp
的毫秒数May 30, 2024
,然后除以1000
将其转换为秒,并将其传递给FlipDown
构造函数
const finalDate = new Date('2024-05-30T00:00:00Z').getTime() / 1000;
// Set up FlipDown
const flipdown = new FlipDown(finalDate)
// Start the countdown
.start()
// Do something when the countdown ends
.ifEnded(() => {
console.log('The countdown has ended!');
});