How to get milliseconds timestamp in gdscript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hsn


I want to get milliseconds on the timestamp e.g date time seconds milliseconds. I know there is a way to get milliseconds using


but this returns the time elapsed till the game started however I want to know the current date time seconds milliseconds.


Do you mean get_system_time_msecs? Or for a timer in the game?

Magso | 2019-11-21 21:55


Thanks alot it works perfectly fine.


hsn | 2019-11-21 22:08

@magso can you please write it as answer so I should vote it for the best answer then ?

hsn | 2019-11-21 22:09

Well, the answer is rtfm seeing as get_system_time_msecs() is two up from get_ticks_msec() in the docs.

Magso | 2019-11-21 22:41

:bust_in_silhouette: Reply From: hsn


There is no such function in Godoto 3.3.
But OS.get_system_time_msecs() which gives ms time sind 1970 and not the current system time.

Losatu | 2021-09-26 10:14

:bust_in_silhouette: Reply From: Losatu

to get current ms of the system you will have to do

OS.get_system_time_msecs() - OS.get_system_time_secs()*1000

as get_system_time_secs does not have the ms, it will get ms by *1000, but ms is there 0.
Therefore the subtraction gives the current ms of the system.

:bust_in_silhouette: Reply From: RufusWein

Now on Godot 4 it is replaced by Time.get_ticks_msec()

More info visit: Time — Godot Engine (stable) documentation in English

Should be: Time.get_ticks_msec(). Unwanted italics crept in.

saletrak | 2023-05-16 01:18

Check How to get time in milliseconds/milliseconds timestamp in gdscript? - #3 by hotpepper for an updated answer for the latest Godot 4 which is a true “Timestamp” (in the sense it starts from 1970 rather than from when the program was started).