GetServerTimeNow doesn't return same time between 2 servers

So, according to the documentation:
image

image

My friend and I were testing how accurate it was, and it turns out that we have a ~1-minute time difference.

Me My Friend
1757119780.129153 1757119718.66684

These were printed on the server each time


Is that normal? If yes, is there a better solution to this
Keynote: This was done in Testing mode in the studio

GetServerTimeNow() is not synced across all servers.

You can use os.clock() which is synced across all servers

1 Like

The answers are completely in the documentation you copy pasted.
“GetServerTimeNow is less precise than os.clock”.
Use os.clock() instead as @sie said.

workspace:GetServerTimeNow() returns the unix timestamp according to the server’s time, it’s intended to be used from the client to keep in sync with the server, and the inaccuracies between studio sessions you’re seeing is likely because either you or your friend’s system clock is off (or both) – you might want to resynchronize that in your system’s time settings.
This shouldn’t be an issue in live servers as the datacenters should be maintained.

os.clock() returns the number of seconds since an arbitrary baseline, useful for keeping track of time on the same machine with high precision, not so much for synchronizing between servers or clients though.

os.time() is superceded by the DateTime API, use of the latter is recommended.

3 Likes

Hey, just wondering, does os.clock() not just show DateTime.now() and GetServerTimeNow() as inferior? I don’t understand the key differences

os.clock() returns the number of seconds since an arbitrary baseline, it does not return a unix timestamp. It’s useful for high precision timekeeping like benchmarks.

2 Likes

Thanks for this

I was typing on phone and just saw this message because the chat box was blocking my view

1 Like

os.clock() returns the time since the process started;

it can’t be used to sync servers.


You were right! Thank you so much. Turns out GetServerTimeNow() has milliseconds of delay in LiveServers.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.