Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ooh, just seen I'm a bit slow with this, but it seems to work so I'll add it anyway. :)</p> <pre><code>function parseTime() { var timeLeftStr; var timeLeft = 0; timeLeftStr = document.getElementById("timeleft").innerHTML; timeLeftStr.replace(/(\d+):(\d+):(\d+)/, function () { for (var i = 1; i &lt; arguments.length - 2; i++) { // Convert to ms timeLeft += arguments[i] * Math.pow(60, 3 - i) * 1000; } }); countdown(new Date(timeLeft)); } function countdown(timeLeft) { var hours = timeLeft.getUTCHours(); var minutes = timeLeft.getUTCMinutes(); var seconds = timeLeft.getUTCSeconds(); if (timeLeft.valueOf() == 0) { document.getElementById("timeleft").innerHTML = ""; window.location = 'test.php?pageid=' + getURLParam("pageid"); return false; } else { document.getElementById("timeleft").innerHTML = (hours == 0 ? "" : hours + (hours == 1 ? " hour" : " hours")) + (minutes == 0 ? "" : (hours ? (seconds ? ", " : " and ") : " ") + minutes + (minutes == 1 ? " minute" : " minutes")) + (seconds == 0 ? "" : (hours || minutes ? " and " : "") + seconds + (seconds == 1 ? " second" : " seconds")); setTimeout(function () { countdown(new Date(timeLeft - 1000)); }, 1000); } } window.onload = parseTime; </code></pre> <p><strong>Edit</strong> to remove <code>skip</code>.</p> <p><strong>Edit 2</strong> to remove start &amp; end checks on regex, add <code>,</code> and <code>and</code> support.</p> <p><strong>Edit 3</strong> to use <code>getUTCHours</code>, etc. so it works in other timezones (oops). </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload