+9 votes

Hi, I am new to GDScript. Been trying to look at the API but I don't seem to find anything related to date and time. How do I get the system time?

in Engine by (57 points)

2 Answers

+12 votes
Best answer

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;
by (1,277 points)
selected by

Thanks! This is exactly what I'm looking for :)

no problem :)

0 votes

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)
by (29 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.