From 1d7696c5b8364c00528eacea263334e84553358b Mon Sep 17 00:00:00 2001 From: Sam Sneed <163201376+sam-sneed@users.noreply.github.com> Date: Sat, 10 Aug 2024 10:54:50 -0500 Subject: [PATCH] Add files via upload --- countdown.js | 30 ++++++++++++++++++++++++++++++ index.html | 32 ++++++++++++++++++++++++++++++++ styles.css | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 countdown.js create mode 100644 index.html create mode 100644 styles.css diff --git a/countdown.js b/countdown.js new file mode 100644 index 0000000..48e211e --- /dev/null +++ b/countdown.js @@ -0,0 +1,30 @@ +document.addEventListener('DOMContentLoaded', function () { + // Set the date for January 1st of the following year + const targetDate = new Date(); + targetDate.setFullYear(targetDate.getFullYear() + 1); + targetDate.setMonth(0); + targetDate.setDate(1); + targetDate.setHours(0, 0, 0, 0); + + // Update the countdown every second + setInterval(updateCountdown, 1000); + + function updateCountdown() { + const currentDate = new Date(); + const timeDifference = targetDate - currentDate; + + const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24)); + const hours = Math.floor((timeDifference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + const minutes = Math.floor((timeDifference % (1000 * 60 * 60)) / (1000 * 60)); + const seconds = Math.floor((timeDifference % (1000 * 60)) / 1000); + + document.getElementById('days').textContent = formatTime(days); + document.getElementById('hours').textContent = formatTime(hours); + document.getElementById('minutes').textContent = formatTime(minutes); + document.getElementById('seconds').textContent = formatTime(seconds); + } + + function formatTime(time) { + return time < 10 ? `0${time}` : time; + } +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..4bf1fef --- /dev/null +++ b/index.html @@ -0,0 +1,32 @@ + + +
+ + + +