// The date you want to count down to var targetDate = new Date("2026/1/1 00:00:00"); // Variables var days; var hrs; var min; var sec; $(function() { // Calculate time until launch date timeToLaunch(); // Display the initial countdown values $("#days .number").text(days); $("#hours .number").text(hrs); $("#minutes .number").text(min); $("#seconds .number").text(sec); // Begin Countdown setTimeout(countDownTimer, 1000); }); function timeToLaunch(){ // Get the current date var currentDate = new Date(); // Find the difference between dates var diff = (targetDate - currentDate) / 1000; var diff = Math.abs(Math.floor(diff)); // Check number of days until target days = Math.floor(diff / (24 * 60 * 60)); var remainder = diff - days * 24 * 60 * 60; // Check number of hours until target hrs = Math.floor(remainder / (60 * 60)); remainder = remainder - hrs * 60 * 60; // Check number of minutes until target min = Math.floor(remainder / 60); sec = remainder - min * 60; // Format hours, minutes, and seconds as two digits hrs = String(hrs).padStart(2, '0'); min = String(min).padStart(2, '0'); sec = String(sec).padStart(2, '0'); } /* Display Countdown */ function countDownTimer(){ // Update time variables timeToLaunch(); // Write to countdown component with formatted values $("#days .number").text(days); $("#hours .number").text(hrs); $("#minutes .number").text(min); $("#seconds .number").text(sec); // Repeat every second setTimeout(countDownTimer, 1000); }