Topic was automatically imported from the old Question2Answer platform.
Asked By
wombatTurkey
Old Version
Published before Godot 3 was released.
I’ve been googling this for a while, and I’m trying to create a tcp latency logger. But having trouble because I need to get the time difference in milliseconds not just seconds:
I found these:
OS.get_system_time_secs
and
OS.get_unix_time
but seems like there is no millisecond method available yet? I’m looking over the docs now
Looks like I found something that will work: OS.get_ticks_msec()
Edit: Yep, this works! Awesome, sorry guys I was just getting worried
But this returns only elapsed milliseconds after app starts.
It’s not exactly unix millisecond timestamp which I need for sometimes.
I think It would be added 3.0
volzhs | 2016-08-05 14:05
Be that as it may, this is certainly better than using something like OS.get_timestamp, which returns a dictionary of sub-components (hours, minutes, etc.) which is not easy to compare.
nightblade9 | 2018-09-03 11:19
Based on this, you can get milliseconds by doing
OS.get_ticks_msec() % 1000
It should return a value of 0 - 999
but I’m not sure if this is the actual milliseconds or this is dependent on something else. Hope someone can affirm this is milliseconds.
Cons to this method of getting milliseconds is that you are basically asking the computer to do more math whenever you run this line. hope there will be one command to get milliseconds on godot 4.0