* xana...@gmail.com <xana...@gmail.com> [170915 03:16]:
> No the clients are connected to this app through websockets, they are using 
> javascript, following snippet is used to make the countdown:
> let timeLeft = Math.ceil(((timestamp * 1000) - new Date().getTime()) / 1e3)

Okay, so the clients are on different machines, with no guarantee that
the clocks on the server and client machines are synchronized.  Also, I
am guessing (since you did not answer that part of my question), that
you believe the time is off by 3 sec because the client sees a timeLeft
that is 93 sec, when timestamp was generated on the server machine.

Hopefully, the reason the client sees a countdown starting at 93 instead
of 90 (and, perhaps, ending at 3 instead of 0) should now be obvious to
you:  the client and server clocks have a 3-second difference, and you
are taking a time value created on the server and then using it on the
client.

Does this answer your question?

...Marvin

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to