Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload = function () {
- var countdown_start_in_ms = 6000; // from server
- function tick() {
- var now = new Date().getTime();
- var disp = start - now;
- if (disp < 0) {
- disp = 0;
- }
- var el = document.getElementById("countdown");
- el.innerHTML =
- // quick hack to format time
- /(dd:dd:dd) ...$/.exec(new Date(disp).toUTCString())[1];
- if (disp > 1000) {
- var elapsed = new Date().getTime() - now;
- window.setTimeout(tick, 1000 - elapsed);
- } else {
- // stop countdown and set color to light grey
- el.style.color = "#ccc";
- }
- }
- var start = new Date().getTime() + countdown_start_in_ms;
- tick();
- }
- $('#until2d4h').countdown({until: '+12M +54S'});
Add Comment
Please, Sign In to add comment