Countup from set date and time
<p>I have a webpage that, when you click start patrolling, starts counting the time since you clicked the button. Because I need to store this on the server (ASP.NET) and because I want to resume the count when they reload the page, I get two variables from the server. The first variable is the server time they clicked the start patrolling button. The second variable is the offset of the local time from the server time so we are 100% exact on the amount of time and it isn't off because of the local time. The following code works but the hours are WAY off. Currently the local time is 19:53 and if this function runs it starts at "18:00:00" and then goes up "18:00:01", "18:00:02" etc... If the local time was 20:53 it would be "19:00:00". Why is this function doing this and how can I correct this?</p>

<p><strong>patroltimeCurrentTimeoffset</strong> is the returned offset value (EG: -729)</p>

<p><strong>patroltimeStart</strong> is the date and time the on the server that the user started patrolling (EG: April 10, 2012 20:01:13)</p>

<pre><code>function UpdatePatrolTime() {
        var patroltimeCurrentTime = new Date();

        patroltimeCurrentTime.setTime(patroltimeCurrentTime.getTime() + patroltimeCurrentTimeoffset);

        var patroltimeStarted = new Date(patroltimeStart);
        var CompareDateTime = new Date((patroltimeCurrentTime.getTime()-patroltimeStarted.getTime()));

        currentHours = CompareDateTime.getHours();
        currentMinutes = CompareDateTime.getMinutes();
        currentSeconds = CompareDateTime.getSeconds();

        currentHours = (currentHours &lt; 10 ? "0" : "") + currentHours;
        currentMinutes = (currentMinutes &lt; 10 ? "0" : "") + currentMinutes;
        currentSeconds = (currentSeconds &lt; 10 ? "0" : "") + currentSeconds;

        var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds

        document.getElementById("patroltime").firstChild.nodeValue = currentTimeString;
    }
</code></pre>

<p>And the &lt;span&gt; control:</p>

<pre><code>&lt;span id="patroltime"&gt;00:00:00&lt;/span&gt;
</code></pre>
