SYSTEMTIME_TO_DT

SYSTEMTIME_TO_DT 1:

The "SYSTEMTIME_TO_DT" function allows the Windows system time structure to be converted to the DATE_AND_TIME format (DT) usual in a PLC. The system time has a resolution of 1 ms and the DATE_AND_TIME has a resolution of 1 s. The milliseconds from the system time are taken into account during the conversion and rounded up to the DATE_AND_TIME return value accordingly. To disable rounding, set the wMilliseconds element in the Windows system time structure to zero.

FUNCTION SYSTEMTIME_TO_DT : DT

SYSTEMTIME_TO_DT 2: Inputs

VAR_INPUT
    TIMESTR : TIMESTRUCT;
END_VAR

Name

Type

Description

TIMESTR

TIMESTRUCT

The structure with the Windows system time to be converted

Example:

PROGRAM SystemTimeTest
VAR
    SystemTimeStruct  : TIMESTRUCT;
    DTFromSystemTime  : DT;
END_VAR

SYSTEMTIME_TO_DT 3:

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)