You are offline. The tools work from the copy saved in this browser; pages you have not opened yet need a connection.
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
ExampleRaw 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
| Byte | Field | Raw | Value |
|---|
Same time with each time base
| Time base | Units | Raw | Value |
|---|
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).
| Type | Stored as | Range · Example (hex) |
|---|---|---|
| S5TIME2 B | Bits 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 B | DINT, signed milliseconds. | T#-24D_20H_31M_23S_648MS … T#24D_20H_31M_23S_647MST#1H_1M = 0037 D8E0 |
| DATE2 B | UINT, days since 1990-01-01. | D#1990-01-01 … D#2168-12-31D#2009-12-31 = 1C88 |
| TIME_OF_DAY4 B | UDINT, milliseconds since midnight. | TOD#00:00:00 … TOD#23:59:59.999TOD#10:20:30.400 = 0238 1740 |
| DATE_AND_TIME8 B | 8 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 B | UINT 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
- Reading S5TIME as an integer. 2127 hex is 8487 as a number, but as S5TIME it is 127 s. The time value is BCD, and the top digit is the time base.
- Expecting S5TIME to be exact. With a time base of 10 ms only up to 9.99 s fits. S5T#1S_234MS is stored as 1.23 s, and anything over 2H_46M_30S does not fit at all.
- DT years. DATE_AND_TIME has only two BCD digits for the year: 90 to 99 are 1990 to 1999 and 00 to 89 are 2000 to 2089. Dates after 2089 need DTL.
- Swapped bytes. Some gateways and SCADA drivers swap the two bytes of each register. A DTL year that reads 55303 instead of 2008 (07D8 read as D807) is the typical sign.
- Trusting the weekday. The weekday in DT and DTL follows from the date, and for DTL STEP 7 ignores it when you enter a value. If it disagrees with the date, the date wins.
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
- 4–20 mA ScalingRaw values to engineering units, 0–10 V and 4–20 mA with fault detection.
- IEEE 754 ConverterFloat32 and Float64 to hex and back, bit by bit, with registers for every byte order.
- CRC-8 / CRC-16 / CRC-32 CalculatorAny CRC from 3 to 82 bits: 113 named algorithms, your own parameters, and finding which CRC a device uses.
- P1 Telegram Decoder (DSMR)Decode a smart meter P1 telegram (DSMR, Belgian e-MUCS): OBIS codes, CRC check, power per phase, gas and water.
- Pt100 / Pt1000 CalculatorResistance to temperature and back per IEC 60751, with 2-wire lead error and tolerance classes.
- Thermocouple CalculatormV to °C and back for types K, J, T, E, N, R, S and B, with cold junction compensation.
- Register DecoderFloat32, Int32, UInt16 and bits in every byte order, plus Find my value.
- Address Converter40001 ↔ offset 0, 4x/3x/0x/1x notation, 5- and 6-digit addresses.
- Value EncoderTurn a value like 230.5 into registers for every byte order.
- CRC-16 CalculatorModbus RTU checksum in wire order, plus a full frame check.
- Frame DecoderRead RTU and TCP frames from Wireshark or a serial log.
- Request GeneratorRead and write requests in RTU, TCP and ASCII, plus a check of the reply.
- Frame ConverterThe same Modbus frame as RTU, TCP and ASCII, with CRC, header and LRC recalculated.
- Function & Exception CodesWhat each code means and the usual cause in practice.
- Status Word DecoderName each bit of a 16- or 32-bit status register.
- Modbus RTU Timing CalculatorCharacter time, t1.5 and t3.5, frame length, shortest timeout and how many reads per second fit on the line.
- Register mapsReady-made register maps for meters, inverters and batteries.