This article covers the following platforms
MSFS 2024
MSFS 2020
ATS
FSX
Prepar3D
Use the Time API to inspect simulator time and move the simulation clock to a specific offset, time of day, or named solar moment.
get_sun_position()
Get the sun position and relevant times of day.
SignatureTypeScript contract
get_sun_position(): Record<string, unknown>ExampleJavaScript
const sun = this.$api.time.get_sun_position();
console.log(sun);Returns
Record<string, unknown>Object containing the sun position and relevant times of day.get_sim_time_utc()
Get the simulator’s current UTC time.
SignatureTypeScript contract
get_sim_time_utc(): DateExampleJavaScript
const utcTime = this.$api.time.get_sim_time_utc();
console.log(utcTime);Returns
DateSimulator time in UTC.get_sim_time_local()
Get the simulator’s current local time.
SignatureTypeScript contract
get_sim_time_local(): DateExampleJavaScript
const localTime = this.$api.time.get_sim_time_local();
console.log(localTime);Returns
DateSimulator time in the local time zone.set_sun_offset_utc()
Offset the simulator time from its current UTC value.
SignatureTypeScript contract
set_sun_offset_utc(offset: number): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
offset | number | Yes | Time offset in seconds. |
ExampleJavaScript
this.$api.time.set_sun_offset_utc(3600);Returns
voidNo direct return value is documented.set_local_time()
Set the local time of day.
SignatureTypeScript contract
set_local_time(local_time_of_day: number): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
local_time_of_day | number | Yes | Number of seconds since local midnight. |
ExampleJavaScript
this.$api.time.set_local_time(14 * 60 * 60);Returns
voidNo direct return value is documented.set_zulu_time()
Set the Zulu time of day.
SignatureTypeScript contract
set_zulu_time(zulu_time_of_day: number): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
zulu_time_of_day | number | Yes | Number of seconds since midnight in Zulu time. |
ExampleJavaScript
this.$api.time.set_zulu_time(18 * 60 * 60);Returns
voidNo direct return value is documented.set_time_by_moment()
Set simulator time using a supported named solar moment.
SignatureTypeScript contract
set_time_by_moment(moment: string): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
moment | string | Yes | One of the supported moment values listed below. |
ExampleJavaScript
this.$api.time.set_time_by_moment("goldenHourDawnStart");Returns
voidNo direct return value is documented.Supported moment values
| Value | Behavior |
|---|---|
live |
Real time |
solarNoon |
Solar noon, when the sun is highest |
nadir |
Darkest moment of night, when the sun is lowest |
goldenHourDawnStart |
Start of the morning golden hour |
goldenHourDawnEnd |
End of the morning golden hour |
goldenHourDuskStart |
Start of the evening golden hour |
goldenHourDuskEnd |
End of the evening golden hour |
sunriseStart |
Top edge of the sun appears on the horizon |
sunriseEnd |
Bottom edge of the sun reaches the horizon |
sunsetStart |
Bottom edge of the sun reaches the horizon |
sunsetEnd |
Sun disappears below the horizon |
blueHourDawnStart |
Start of the morning blue hour |
blueHourDawnEnd |
End of the morning blue hour |
blueHourDuskStart |
Start of the evening blue hour |
blueHourDuskEnd |
End of the evening blue hour |
civilDawn |
Morning nautical twilight ends and civil twilight starts |
civilDusk |
Evening nautical twilight starts |
nauticalDawn |
Morning nautical twilight starts |
nauticalDusk |
Evening astronomical twilight starts |
amateurDawn |
Sun reaches 12° below the horizon before sunrise |
amateurDusk |
Sun reaches 12° below the horizon after sunset |
astronomicalDawn |
Night ends and morning astronomical twilight starts |
astronomicalDusk |
Night starts |