views:

80

answers:

1

Hi,

I'm searching for an example with an client timer that ticks synchronous with an server timer. Also there must be a button on the client side which can reset the server timer to an default value, and with this it also resets the client timer ofcourse.

I tried it myself but it seems that there is some postback delay which makes it impossible for me to make it atleast look like it goes synchronous.

I hope somebody got an example for me, the button part is really important because by pressing that button the delay comes.

Thanks in advance,

Julian

A: 

write server offset into response like JSON or any other way and use it as parameter for next method

function getServerTime(serverOffset)
{
    var myDate=new Date();
    myDate.setDate(myDate.getTime()+(serverOffset*60*60*1000));
    return myDate;
}

this method you can call each second and put returned value where ever you want.

TriLLi
True,it does, but as told in the topic the problem is the button press. I see some delay in the press and the reset of the client/server timer.
Julian
than just measure time from begin till end of request, and add that time to offset and you will have right time, or you can get timezone of server and generate time for that timezone
TriLLi
Got any good link for measuring the request time?
Julian