$(document).ready(function() { let clock; // Grab the current date let currentDate = new Date(); // Target future date/24 hour time/Timezone let targetDate = moment.tz("2022-06-30 23:59", "Asia/Jakarta"); // Calculate the difference in seconds between the future and current date let diff = targetDate / 1000 - currentDate.getTime() / 1000; if (diff <= 0) { // If remaining countdown is 0 clock = $(".clock").FlipClock(0, { clockFace: "DailyCounter", countdown: true, autostart: false }); console.log("Date has already passed!") } else { // Run countdown timer clock = $(".clock").FlipClock(diff, { clockFace: "DailyCounter", countdown: true, callbacks: { stop: function() { console.log("Timer has ended!") } } }); // Check when timer reaches 0, then stop at 0 setTimeout(function() { checktime(); }, 1000); function checktime() { t = clock.getTime(); if (t <= 0) { clock.setTime(0); } setTimeout(function() { checktime(); }, 1000); } } }); function generate_year_range(start, end) { var years = ""; for (var year = start; year <= end; year++) { years += ""; } return years; } today = new Date(); currentMonth = today.getMonth(); currentYear = today.getFullYear(); selectYear = document.getElementById("year"); selectMonth = document.getElementById("month"); createYear = generate_year_range(1970, 2050); /** or * createYear = generate_year_range( 1970, currentYear ); */ document.getElementById("year").innerHTML = createYear; var calendar = document.getElementById("calendar"); var lang = calendar.getAttribute('data-lang'); var months = ""; var days = ""; var monthDefault = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]; var dayDefault = ["Ming", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"]; if (lang == "en") { months = monthDefault; days = dayDefault; } else if (lang == "id") { months = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"]; days = ["Ming", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"]; } else if (lang == "fr") { months = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"]; days = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]; } else { months = monthDefault; days = dayDefault; } var $dataHead = "