07-15-2015, 04:19 PM
It's an easy calculation (any errors are due to my lazyness). Lets assume all times are in unix format ( defined as the number of seconds that have elapsed since 1 January 1970)
Then:
Where time_coop is 20:00 CET converted to unix time
However, time_server is only known on page loading, and is static, so we need the difference between the local machine time and the server time at page loading:
time_diff_local is now the number of seconds your local clock is in advance of the server, which is zero if your local clock is set exactly like the server.
Now we can countdown from the local time, and update the text at any time (that is crucial as Alwarren correctly notes):
Hope that clears it up
Then:
Code:
time_to_coop = time_coop - time_server.
However, time_server is only known on page loading, and is static, so we need the difference between the local machine time and the server time at page loading:
Code:
time_diff_local = time_local - time_server.Â
Now we can countdown from the local time, and update the text at any time (that is crucial as Alwarren correctly notes):
Code:
time_to_coop = time_coop - (time_local - time_diff_local).
Hope that clears it up