SYSTEMTIME_TO_DT
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 1ms, while the resolution of DATE_AND_TIME is 1s. The milliseconds from the system time are used in the course of the conversion to determine the direction of rounding for the returned DATE_AND_TIME value. To disable rounding, set the wMilliseconds element in the Windows system time structure to zero.
FUNCTION SYSTEMTIME_TO_DT: DT
VAR_INPUT
VAR_INPUT
TIMESTR : TIMESTRUCT;
END_VAR
TIMESTR: The structure with the Windows system time requiring conversion (type: TIMESTRUCT).
Example:
PROGRAM SystemTimeTest
VAR
SystemTimeStruct : TIMESTRUCT;
DTFromSystemTime : DT;
END_VAR
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) |