DT_TO_SYSTEMTIME
The "DT_TO_SYSTEMTIME" function allows a PLC variable in DATE_AND_TIME format (DT) to be converted to a Windows system time structure. The system time has a resolution of 1ms, while the resolution of DATE_AND_TIME is 1s. The "wMilliseconds" variable in the system time structure therefore always returns the value zero.
FUNCTION DT_TO_SYSTEMTIME : TIMESTRUCT
VAR_INPUT
DTIN : DT;
END_VAR
DTIN:: The date and time to be converted, in DATE_AND_TIME format.
Example of a call in FBD:
PROGRAM SystemTimeTest
VAR
SystemTimeStruct :TIMESTRUCT;
END_VAR
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 | PC or CX (x86) | Standard.Lib; PLCSystem.Lib; TcPLCAds.Lib; PLCHelper.Lib; TcPlcUtilities.Lib |
TwinCAT v2.8.0 and above | PC or CX (x86) | TcUtilities.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically ) |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) |