PLCBytes
Converters & calculators

S5TIME, DT and DTL Converter

Pick a Siemens S7 time format and enter either the raw hex from the PLC or the value. The other side is filled in, with every byte explained and the registers you read over Modbus.

Value

Example
Format

Raw hex as stored in the PLC, high byte first: 2127, 0x2127 or 21 27. Modbus registers of a DB give the same bytes in the same order.

Result

Readable
Bytes
Modbus registers (hex)
Modbus registers (decimal)

What each byte means

ByteFieldRawValue

Same time with each time base

Time baseUnitsRawValue

STEP 7 picks the finest time base that fits (marked) and rounds down to it. A coarser base gives the same time with less resolution, which matters when a timer is preset from a calculated value.

Runs entirely in your browser. Nothing you enter is sent to a server.

Siemens S7 time and date formats

Byte layouts and ranges from the Siemens manuals Programming with STEP 7 (A5E41552389-AA) and S7-1200 System Manual (A5E02486680-05).

TypeStored asRange · Example (hex)
S5TIME2 BBits 12–13 time base (10 ms, 100 ms, 1 s, 10 s), bits 0–11 three BCD digits 0–999.S5T#0MS … S5T#2H_46M_30SS5T#2M_7S = 2127
TIME4 BDINT, signed milliseconds.T#-24D_20H_31M_23S_648MS … T#24D_20H_31M_23S_647MST#1H_1M = 0037 D8E0
DATE2 BUINT, days since 1990-01-01.D#1990-01-01 … D#2168-12-31D#2009-12-31 = 1C88
TIME_OF_DAY4 BUDINT, milliseconds since midnight.TOD#00:00:00 … TOD#23:59:59.999TOD#10:20:30.400 = 0238 1740
DATE_AND_TIME8 B8 bytes BCD: year (90–99 = 1990s, 00–89 = 2000s), month, day, hour, minute, second, three digits of milliseconds, weekday in the last 4 bits.DT#1990-01-01-00:00:00 … DT#2089-12-31-23:59:59.999DT#1993-12-25-08:12:34.567 = 9312 2508 1234 5677
DTL12 BUINT year, USINT month, day, weekday, hour, minute, second, UDINT nanoseconds.DTL#1970-01-01-00:00:00 … DTL#2554-12-31-23:59:59.999999999DTL#2008-12-16-20:30:20.25 = 07D8 0C10 0314 1E14 0EE6 B280

Siemens, SIMATIC and STEP 7 are trademarks of Siemens AG. PLCBytes is an independent project, not affiliated with or endorsed by Siemens.

How Siemens stores times and dates

Siemens S7 controllers have several time formats, and a value read from a data block or over Modbus is just bytes until you know which one it is. The old S5TIME from S5 and S7-300/400 timers packs a time base and a three-digit BCD number into one word: 2127 hex means time base 1 s (code 2) and 127 units, so 127 s. TIME is a signed 32-bit count of milliseconds, DATE counts days from 1990-01-01 and TIME_OF_DAY milliseconds from midnight. DATE_AND_TIME (DT) stores date and time as eight BCD bytes, so 1993 appears as the hex byte 93. DTL on S7-1200 and S7-1500 is a 12-byte structure of plain binary numbers with nanoseconds.

All formats are stored with the high byte first. When a DB is shared over Modbus TCP, register 1 holds bytes 0 and 1, register 2 bytes 2 and 3, and so on, which is exactly what the tool shows. To check other values in the same registers, use the register decoder.

S5TIME to TIME and INT in the PLC

On the S7-300 and S7-400 the IEC function FC33 S5TI_TIM from the standard library converts S5TIME to TIME, and FC40 TIM_S5TI converts TIME back to S5TIME. TIM_S5TI rounds down, and anything over 2H_46M_30S becomes the maximum, 999 × 10 s. TIME is a DINT of milliseconds, so dividing it by 1000 gives whole seconds as an integer. On the S7-1200 the T_CONV instruction converts between Time and DInt.

Common mistakes

Questions from practice

How do I convert S5TIME to seconds, TIME or INT?

Take the first hex digit as the time base: 0 = 10 ms, 1 = 100 ms, 2 = 1 s, 3 = 10 s. The other three hex digits are the BCD value, read them as a decimal number. Multiply the two: 2127 is 127 × 1 s = 127 s, 1100 is 100 × 100 ms = 10 s. In the PLC, FC33 S5TI_TIM does the same and returns TIME in milliseconds.

What is the maximum S5TIME?

2H_46M_30S, that is 999 × 10 s = 9990 s, stored as 3999 hex. For longer times use TIME (up to about 24.8 days) or count in your own program.

How do I read a DTL over Modbus?

A DTL takes 12 bytes, so 6 holding registers: year, month and day, weekday and hour, minute and second, and the nanoseconds in two registers, high word first. Paste the 6 registers as hex into the raw field to see the date and time.

What is the difference between DT and DTL?

DATE_AND_TIME (DT) has 8 bytes in BCD, covers 1990 to 2089 and stores milliseconds. DTL has 12 bytes of normal binary numbers, covers 1970 to 2554 and stores nanoseconds. DTL is the format of S7-1200 and S7-1500, DT comes from S7-300 and S7-400.

How is a DATE stored?

As an unsigned 16-bit number of days since 1 January 1990. 0 is D#1990-01-01, 7304 (1C88 hex) is D#2009-12-31 and the largest date is D#2168-12-31.

Related tools