I have two scripts one in PHP to get the time server side, and the other is a JavaScript countdown based on a date and time. I am not sure what I am doing wrong, but when I
I had problems with @Ghostoy's var distance = end - now;
I noticed my seconds counting down would often pause and skip a number every once in a while. When I displayed the distance, I noticed the milliseconds were shifting a little back and forth.
For example, as I watched the distance countdown, these were my results:
400996000
400995001
400993998
400993002
400991999
Could be just my computer, but if the problem happens on my machine, then it could happen to someone else. As a result, I suggest changing var distance to this:
var distance = Math.round((end - now)/1000)*1000;
This fixed it on my machine.