Good morning,
I'm trying to put on my website a timer, that reset evey day at 00:00 UTC +1 (Rome), and start again. The fact is that is more complex than this... The timer need to start at 00:00. On the website, ppl will see 23:00:00 remaining. For the one hour remaining until 00:00, so from 23:00 until 00:00, on the website ppl will see "Results will be published within one hour, the game will restart in "countdown one hour"" and at 00:00 everything will resset.
the JS code that I have from my template is:
if (plugins.countDown.length) {
var d;
for (i = 0; i < plugins.countDown.length; i++) {
var countDownItem = plugins.countDown[i],
d = new Date(),
time = countDownItem.getAttribute('data-time'),
type = countDownItem.getAttribute('data-type'), // {until | since}
format = countDownItem.getAttribute('data-format') ? countDownItem.getAttribute('data-format') : 'YYYY/MM/DD hh:mm:ss',
expiryText = countDownItem.getAttribute('data-expiry-text') ? countDownItem.getAttribute('data-expiry-text') : 'Countdown finished',
labels = countDownItem.getAttribute('data-labels') ? countDownItem.getAttribute('data-labels') : '',
layout = countDownItem.getAttribute('data-layout') ? countDownItem.getAttribute('data-layout') : '{yn} {yl} {on} {ol} {dn} {dl} {hnn}{sep}{mnn}{sep}{snn}',
settings = [];
if (labels.length > 0) {
settings['labels'] = JSON.parse(labels);
}
d.setTime(Date.parse(time)).toLocaleString();
settings[type] = d;
settings['expiryText'] = expiryText;
settings['format'] = format;
settings['alwaysExpire'] = true;
settings['padZeroes'] = true;
settings['layout'] = layout;
settings['onExpiry'] = function () {
this.classList += ' countdown-expired';
this.innerHtml = expiryText;
};
$(countDownItem).countdown(settings);
}
}
just a simple count down.