OS Time Consistency

Is OS Time the same on both the server and the client if theoretically called at the same time?

I believe you may be looking for this.

Probably yes,
but roblox ticks might affect real-time accuracy, read on how to utilise the OS module.

It’s not, it’s actually different. os.date and os.time will be relevant to the client’s timezone (it’s named os meaning operating system so it makes sense for it to be dependant on the client’s computer), so each client would have different returns from these two functions. The server also has his different return, not sure what timezone it is, but I assume it would be set according to the location of the roblox servers.

If you’re looking for a way to count time the same way everywhere, use tick(), which is correspondant to the 1970 epoch, so it would always be the same, everywhere

Not for os.date. It will only return time relative to the client’s timezone if you specify it to do so using the *t tag. !*t will return time since the UNIX Epoch in UTC.

UTC. If not that, it probably returns time relative to the region of the server.

So is os.time.

2 Likes

does os time ever return the client’s specific time zone??

I don’t really work with os.time on the client (I’ve only ever had need for it on the server in the past), so not sure. There’s probably some information floating around somewhere about this. That being said, I’m assuming it doesn’t based on the results of testing.

A quick test in Studio showed that os.time on both the client and server return relatively the same time, it’s just that I had a 3-second discrepancy because server scripts run quicker than LocalScripts even after I put the LocalScript in ReplicatedFirst.

print(os.time())
-- Server: 1581205456
-- Client: 1581205459

These times are based on UTC rather than server region or client timezone. You could probably fix something together involving os.date and *t date formatting, then passing that to os.time. I wouldn’t recommend doing that though since that’d incur some extra overhead, albeit negligible.

You can use tick and ignore the fractionals (miliseconds) if you want time in seconds relative to the client’s timezone.