Does os-time return time less than seconds?

Hello I was try to make a quick benchmark between client and server, but I have notice that when comparing with os.time it wouldn’t return any numbers past the decimal point. So I was trying to know if there is any way that I can retrieve the numbers past the decimal?

local increment = 0
repeat 
print(os.time() ) -- for example 1751981518 -- no decimal!
print(tick() ) -- for example 1751981518.3524965 -- decimals!
task.wait(.2)
until increment > 25
2 Likes

Are there any other better options to use rather than os.time() for the client while still being able to compare with the server with workspace:GetServerTimeNow()?

How about os.Clock() this should include milliseconds.

I have tried using that but it will alway have a huge difference due to it having a difference starting time than workspace:GetServerTimeNow()

os.time returns seconds, you can use DateTime.now() for a more exact representation:

I’ve tried it and it doesn’t seem to return any milliseconds I think there is an function in the game to change the type of return time.

DateTime | Roblox Creator Documentation seems to be what you want.

local now = DateTime.now()
print("now in ms:", now.UnixTimestampMillis)
print("now in sec but precise:", now.UnixTimestampMillis / 1000)
print("now in sec but not precise:", now.UnixTimestamp)
3 Likes

I will mark it as the solution even though its a bit wonky in a loop print.

– Edit:

I have noticed now that workspace:GetServerTimeNow has the decimal in order to give it the precise time which is in microseconds, while all the other ones just use milliseconds.