In this article, we will explain how to use the DateTime class in Unity’s Visual Scripting to obtain date and time information.
What is DateTime?
In Unity, DateTime is a class provided by C#’s standard library for handling date and time information. It is useful for managing time.
Preparation
- Place an empty GameObject in Unity’s scene.
- Attach “Script Machine” to it from Add Component and create a new “Script Graph”.
- Open Menu → Edit → Project Settings, select Visual Scripting, open TypeOption, and press the + button in the lower left.
- Add DateTime and TimeSpan, then press Regenerate Nodes.

Get and Display the Current Time in Console
The following nodes can be used to display the current time:
- Date Time: Get Now
- Using this, you can get the current time.
- Then, convert it to a String type and display it in the Console using Debug.Log.
Point: ToString is not necessary, but it is added to facilitate text display.

Extract Year, Hour, Minute, and Second from the Current Time
Year: Get Year

Hour: Get Hour

Minute: Get Minute

Second: Get Second

These nodes allow you to obtain individual time components.
Specify a Format for Time Display
- Add the Date Time: To String (Format) node.
- Enter the desired output format in the “Format” field. For example:
- yyyy/MM/dd H:mm:ss

You can specify the output format in the Format field.
For this example, we will use [yyyy/MM/dd H:mm:ss].
yyyy | Year |
MM | Month |
dd | Day |
H | Hour |
mm | Minute |
ss | Second |
The output follows the specified format. For example, if “yyyy” is changed to “yy”, 2025 will be displayed as 25.

After execution, the current time is displayed in the Console.

Shift Time from the Current Time
You can shift the time by adding Time Span to Date Time.
Required Nodes
- Add Time Span Create: Time Span (Day, Hour, Minutes, Seconds).
- For example, set it to shift the current time by 1 hour.

In this case, we shift the current time by 1 hour.

When executed, the time shifted by 1 hour is obtained.

The time was successfully shifted by 1 hour.
Conclusion
By using Visual Scripting, you can easily manipulate date and time information. The methods introduced in this article allow you to display time, customize formats, and even perform time calculations. Apply these techniques to implement timers or event scheduling in your game.