system
1
system
4
|
|
|
|
Reply From: |
kubecz3k |
OS.get_time()
returns dictionary with three values: hour
, minute
and second
example:
var timeDict = OS.get_time();
var hour = timeDict.hour;
var minute = timeDict.minute;
var seconds = timeDict.second;
Thanks! This is exactly what I’m looking for
carbajosa | 2016-04-20 18:33
no problem
kubecz3k | 2016-04-20 18:35
is it limited only up to the hour? or can we also get the date of the current time?
Numshv | 2022-10-07 16:50
system
5
|
|
|
|
Reply From: |
george12teodor |
Here is a method to get it in a more curated form
`:
var time = OS.get_time()
var time_return = String(time.hour) +":"+String(time.minute)+":"+String(time.second)
system
6
|
|
|
|
Reply From: |
brooswit |
I had a similar question. I needed the unix timestamp in milliseconds. This function was what I was looking for: OS — Godot Engine (stable) documentation in English
system
7
|
|
|
|
Reply From: |
Luminn |
OS.get_time()
was deprecated in the latest versions of Godot 3 and was removed from Godot 4.
In both Godot 3 and Godot 4, you can use the singleton Time for this task:
Time.get_time_dict_from_system()
to get a dictionary with hour
, minute
, and second
(same behavior as the old OS.get_time()
).
Time.get_time_string_from_system()
can be used to get a preformatted string in the format HH:MM:SS.
And Time.get_datetime_string_from_system()
if you want to include date, the format is YYYY-MM-DDTHH:MM:SS
.
wdv4758h | 2022-10-25 15:43