Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because it was hard to understand your code, so I created a new counter:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; var counterIntervalVar; var howManyDaysAhead = 0; var finishHours = 16; var finishMinutes = 0; var finishSeconds = 0; function ShowTimes() { var str = ""; var now = new Date();//Use current time as start time //Creating the target time var dayIncreasion = 1000 * 3600 * 24 * howManyDaysAhead; var targetDateInMilliSeconds = now.getTime(); var targetDate = new Date(targetDateInMilliSeconds + dayIncreasion); targetDate.setHours(finishHours); targetDate.setMinutes(finishMinutes); targetDate.setSeconds(finishSeconds); targetDateInMilliSeconds = targetDate.getTime(); //Calculate and show the difference between current time and target time var timeDifference = targetDateInMilliSeconds - now.getTime(); if (timeDifference &gt;= 0) { var hrs = Math.floor(timeDifference / 1000 / 3600); var mins = Math.floor(timeDifference / 1000 / 60) - (hrs * 60); sec = Math.floor(timeDifference / 1000) - (hrs * 3600) - (mins * 60); str += '&lt;br&gt;'+hrs+' hours '+mins+' minutes '+sec+' seconds '; document.getElementById('countdownToFour').innerHTML = str; } else { howManyDaysAhead++; } //Give the 'if' query a realistic condition if (str == 'x') { //Stop the loop window.clearInterval(counterIntervalVar); } } function initCountdown() { counterIntervalVar = window.setInterval("ShowTimes()",999); } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="initCountdown()"&gt; &lt;div id="countdownToFour"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Hopefully this example works for you or at least leads you to the right way.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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