DateTime Functions

If you want to use the date and time of a drive-based or a PC-based controller in your AeroScript programs and libraries, you can get this information by using the DateTimeGet() functions. But you cannot set the date and time of the controller through AeroScript. For instructions about how to do this, see the Setting the Controller Date and Time section of Date and Time Configurations.

To get the date and time of the controller, use the DateTimeGet() function that follows. This function shows the date and time represented as the number of seconds since 00:00, Jan 1, 1970 UTC, which is also known as the “common epoch”.

function DateTimeGet() as integer

Gets the current time on the controller.

Returns

The number of seconds since the common epoch.

 

To get the date and time of the controller and set the $dateTimeString argument with a preformatted date and time string, use the DateTimeGet() function overload that follows:

function DateTimeGet(ref $dateTimeString as string) as integer

Gets the current time on the controller.

Arguments

ref $dateTimeString  Output string representation of the current date and time.

Returns

The number of seconds since the common epoch.

You must set $dateTimeString in the sequence of:

[DayOfWeek] [Year] [Month] [Day] [HH:MM:SS] [TimeZone]

Table: $dateTimeString Variables

Argument Description

[DayOfWeek]

The name of the day of the week.

[Year]

The current year.

[Month]

The current month.

[Day]

The current day.

[HH:MM:SS]

The current time with zero-padded values.

[TimeZone]

The name of the time zone that applies to your current location.

IMPORTANT: The names of time zones are different between the PC and Drive-based controllers.

To find the time zones that apply to your controllers:

  • For PC-based controllers, Windows has a default list of time zones. But this list might change based on the version of Windows that you are using. See Default Time Zones.
  • For drive-based controllers, see the Time Zones for Drive-Based Controllers section of Date and Time Configurations.

 

If you want to do date and time operations that are specific to your project, the AeroScript API has a set of functions that you can use to extract individual date and time components from the value that is returned by the DateTimeGet() function.

function DateTimeExtractYear($dateTimeEpoch as integer) as integer

Extracts the year component from the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

The year component of the given date.

function DateTimeExtractMonth($dateTimeEpoch as integer) as integer

Extracts the month component from the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

The month component of the given date [1 - 12].

function DateTimeExtractDay($dateTimeEpoch as integer) as integer

Extracts the day component from the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

The day component of the given date [1 - 31].

function DateTimeExtractHour($dateTimeEpoch as integer) as integer

Extracts the hour component from the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

The hour component of the given date [0 - 23].

function DateTimeExtractMinute($dateTimeEpoch as integer) as integer

Extracts the minute component from the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

The minute component of the given date [0 - 59].

function DateTimeExtractSecond($dateTimeEpoch as integer) as integer

Extracts the second component from the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

The second component of the given date [0 - 59].

function DateTimeExtractDayOfWeek($dateTimeEpoch as integer) as integer

Extracts the day of the week from the day of the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

Integer representing the day of the week since Sunday. [0 - 6]

function DateTimeExtractDayOfYear($dateTimeEpoch as integer) as integer

Extracts the day of the year from the day of the given epoch time.

Arguments

$dateTimeEpoch  The number of seconds from the common epoch.

Returns

Integer representing the days since January 1 [0-365].

Related Topics 

Date and Time Configurations