Constant: TIME, LTIME
You can use TIME constants to operate the standard timer modules. The constant has a size of 32 bits and a resolution in milliseconds.
In addition, the time constant LTIME is available as a time basis for high-resolution timers. The LTIME constant has a dimension of 64 bits and a resolution in nanoseconds.
Constant: TIME
Syntax
<time keyword> # <length of time> <time keyword> : TIME | time | T | t <length of time> : ( <number of days>d )? ( <number of hours>h )? ( <number of minutes>m )? ( <number of seconds>s )? (<number of milleseconds>ms)? // ( ...)? Optional
The order of time units must not be changed. However, it is not required to specify all units. It is permitted to specify the units in uppercase.
Time units
D | d: DaysH | h: HoursM | m: Minutess | s: SecondsMS | ms: Milliseconds
Correct time constants of an ST assignment
VAR
        timLength : TIME := T#14ms;
        timLength1 : TIME := T#100s12ms; // Overflow in the highest unit is allowed.
        timLength2 : TIME := T#12h34m15s;
        timCompare : TIME;
        xIsOK: BOOL;
        timLongest := T#49D17H2M47S295MS; // 4294967295
END_VAR
IF timLength < T#15MS THEN
        IF timCompare < timLength1 THEN
                xIsOK := TRUE;
        END_IF;
END_IFIncorrect usage
  | Overflow at a lower position  | 
  | Time marker   | 
  | Incorrect order of time units  | 
Constant: LTIME
Syntax
<long time keyword> # <length of high resolution time> <long time keyword> : LTIME | ltime <length of high resolution time> : <length of time> ( <number of microseconds>us )? ( <number of nanoseconds>ns )? // ( ...)? Optional
You can use the same units for LTIME constants as for TIME constants. You can also specify microseconds and nanoseconds because the specified time is calculated in higher time resolution. LTIME literals are treated internally as data type LWORD and therefore the value resolved in nanoseconds.
Additional time units
US | us: MicrosecondsNS | ns: Nanoseconds
PROGRAM PLC_PRG
VAR
        ltimLength := LTIME#1000d15h23m12s34ms2us44ns;
        ltimLength1 := LTIME#3445343m3424732874823ns;
END_VARFor more information, see: Data type: TIME, LTIME and Constants: Date and Time