File "countdownTimerCustom.js"

Full Path: /home/westpifz/test.westmars.studio/ptn/css/js/countdownTimerCustom.js
File size: 1.19 KB
MIME-type: text/plain
Charset: utf-8

document.addEventListener('DOMContentLoaded', function () {
            date_for_sale = new Date().getTime();
            date_for_sale = date_for_sale + 60 * 10 * 1000;
            countdown();

        });

        function countdown() {
            var days = 24 * 60 * 60,
                hours = 60 * 60,
                minutes = 60;
            seconds = 1;
            var left = Math.floor((date_for_sale - (new Date().getTime())) / 1000);
            if (left < 0) {
                left = 0;
            }
            h = Math.floor(left / hours);
            if (h < 10) {
                h = '0' + h;
            }
            left -= h * hours;
            m = Math.floor(left / minutes);
            if (m < 10) {
                m = '0' + m;
            }
            left -= m * minutes;

            s = Math.floor(left / seconds);
            if (s < 10) {
                s = '0' + s;
            }
            document.getElementById('hours1').innerHTML = h;
            document.getElementById('min1').innerHTML = m;
            document.getElementById('sec1').innerHTML = s;

            if (h > 0 || m > 0 || s > 0 || d > 0) {
                setTimeout(countdown, 1000);
            }
        }