How to get day from datetime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sprowk
:warning: Old Version Published before Godot 3 was released.

So i tried this: time = OS.get_datetime(OS.get_unix_time())
How can i get from this time only day into variable so i can work with that?

:bust_in_silhouette: Reply From: ericdl

According to the documentation for OS object, get_datetime returns a dictionary of the following keys: (day, dst, hour, minute, month, second, weekday, year).

The key “day” returns the numerical day of the month.

The key “weekday” returns a numerical constant for the day of the week as follows:

DAY_SUNDAY = 0
DAY_MONDAY = 1
DAY_TUESDAY = 2
DAY_WEDNESDAY = 3
DAY_THURSDAY = 4
DAY_FRIDAY = 5
DAY_SATURDAY = 6

To access the “weekday” key for example:

var time = OS.get_datetime()
var dayofweek = time["weekday"]
print(str(dayofweek))