<div class="well" style="font-size:30px;"> <span id="countdown"></span> until our website is released! <script> // set the date we're counting down to // variables for time units var days, hours, minutes, seconds; // get tag element var countdown = document.getElementById("countdown"); // update the tag with id "countdown" every 1 second setInterval(function () { // find the amount of "seconds" between now and target var seconds_left = (target_date - current_date) / 1000; // do some time calculations days = parseInt(seconds_left / 86400); seconds_left = seconds_left % 86400; hours = parseInt(seconds_left / 3600); seconds_left = seconds_left % 3600; minutes = parseInt(seconds_left / 60); seconds = parseInt(seconds_left % 60); // format countdown string + set tag value countdown.innerHTML = days + "d, " + hours + "h, " + minutes + "m, " + seconds + "s"; }, 1000); </script> </div>
Counter działa poprawnie czyli odlicza do określonej daty, jednakże mam następujący problem:
Chciałbym żeby informacje dotyczące daty nie były na sztywno zapisane w kodzie lecz żeby były pobierane z mysql'a. Jak to zrobić?