Date & Time Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Date and Time Calculation > DTO. - Date Time Operations >

Date & Time Operations

DTO.Get Current Time (gct)

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.GetCurrentTime Command

Get the current system time

 

Intention

 

This command retrieves the current time from the computer's system clock. You can specify the desired format for the time string.

 

Available formats:

  0: "HH:MM:SS" (e.g., "14:30:45") - Default

  1: "HH:MM:SS.ttt" (with milliseconds, e.g., "14:30:45.123")

  2: "HHMMSS" (e.g., "143045")

  3: "HH:MM" (e.g., "14:30")

  4: PowerBasic TIME$ format (typically "HH:MM:SS")

  5: "HH:MM:SS AM/PM" (12-hour clock, e.g., "02:30:45 PM")

 

Syntax

 

DTO.getcurrenttime|[Format][|$$RES]

DTO.gct|[Format][|$$RES]

 

Parameter Explanation

 

P1 - Format (Optional)

A numeric value (0-5) specifying the desired time format. If omitted, format 0 ("HH:MM:SS") is used.

 

P2 - $$RES (Optional)

The variable (e.g., $$RES) where the resulting time string will be stored. If omitted, the result is placed on TOS.

 

 

Example

 

'**********************************************

' DTO.gct - Sample (Assumes current time is 14:30:45.123)

'**********************************************

'

' --- Get default format (HH:MM:SS) ---

DTO.gct||$$TIM1

DBV.Default: $$TIM1 ' Result: "14:30:45"

'

' --- Get format with milliseconds ---

DTO.gct|1|$$TIM2

DBV.Milliseconds: $$TIM2 ' Result: "14:30:45.123"

'

' --- Get sortable format (HHMMSS) ---

DTO.gct|2|$$TIM3

DBV.Sortable: $$TIM3 ' Result: "143045"

'

' --- Get 12-hour AM/PM format ---

DTO.gct|5|$$TIM4

DBV.AM/PM: $$TIM4 ' Result: "02:30:45 PM"

'

' --- Get PB TIME$ format to TOS ---

DTO.gct|4

POP.$$TOS

DBV.TIME$: $$TOS ' Result: "14:30:45"

'

ENR.

 

Remarks

 

The time is based on the system's clock and regional settings.

If the format parameter is omitted or invalid, the default format (0) is used.

 

Limitations

 

- The accuracy depends on the correctness of the system clock.

- Does not handle time zones or daylight saving time explicitly.

 

See also

 

    DTO. - Date Time Operations

    DTO.Get Current Date - get current system date

    DTO.Format Time - format time components to string

    DTO.Parse Time - parse time into components

    DAT. - Date and Time Information