TIA Portal Date & Time Instructions Explained (RD_SYS_T, RD_LOC_T & More)
Getting reliable date and time in your Siemens PLC project is critical for traceability, OEE, shift reports and troubleshooting. Yet most programs still only use simple timers and ignore the powerful real-time clock built into modern CPUs.
In my new YouTube tutorial I walk through Date & Time extended instructions in TIA Portal step by step, using S7-1500 / S7-1200 and PLCSIM. This article is the written companion to that video and gives you a quick reference you can bookmark for future projects.
👉 Watch the full video here:
https://www.youtube.com/watch?v=FzSZf3SvCOQ
Why PLC Date & Time Matters
Correct timestamps are no longer a “nice to have” – they’re essential:
- Production and shift reports
- OEE dashboards and performance analysis
- Alarm and event logs that can stand up in audits
- Energy saving modes (night / weekend logic)
- Maintenance reminders and calendar-based tasks
All of that relies on one thing: the PLC knowing the right time and your program using it correctly.
System Time vs Local Time in TIA Portal
TIA Portal differentiates between two concepts:
- System time – the raw time value from the CPU’s real-time clock. Often used as UTC or a plant-wide reference.
- Local time – system time plus time zone and daylight saving adjustments, based on the CPU’s time-of-day settings.
In practice:
- Use system time if you want a neutral reference (for example, for data that will be used across multiple sites or time zones).
- Use local time if you only care about what operators see on HMIs and reports in one location.
The DTL Data Type – Your New Best Friend
For modern Siemens controllers, the key type to know is DTL (Date and Time Long). It conveniently bundles:
- Year, month, day
- Hour, minute, second
- Milliseconds
Working with DTL means you can plug straight into the extended instructions and have access to all the fields you need for logging and logic.
Reading Date & Time: RD_SYS_T and RD_LOC_T
The most common task is simply to read the current PLC time into your program.
- Create a global DB, for example
DB_Clock. - Add two tags:
SystemTime : DTLLocalTime : DTL
- In OB1 (or a time-critical FB), drop the RD_SYS_T instruction and connect its output to
SystemTime. - Add RD_LOC_T and connect its output to
LocalTime.
Now, every PLC cycle:
SystemTimeholds the current system timeLocalTimeholds the local, operator-friendly time
From there you can:
- Use the hour and minute fields for shift logic
- Store full DTL values in log DBs for later analysis
- Pass time values to HMI tags for display
Writing Date & Time: WR_SYS_T and WR_LOC_T
Sometimes you need to update the PLC clock – for example during commissioning or when syncing from a SCADA/HMI.
The two key blocks are:
- WR_SYS_T – write (set) the system time
- WR_LOC_T – write the local time
A typical pattern:
- Create a DTL tag
HMI_TimeSetand a BOOLSetTimeRequest. - Allow the operator (or engineer) to enter date and time on a secure HMI screen.
- When they press “Set clock”, trigger
SetTimeRequestfor one cycle. - Call WR_LOC_T with
IN := HMI_TimeSetand enable it with the request bit.
That’s it – the CPU clock updates. Use WR_SYS_T instead if your policy is to store everything as UTC and handle time zones elsewhere.
⚠️ In a running plant, changing PLC time can affect logs and time-based sequences. Restrict this to commissioning or admin-level screens.
Using Time in Your Logic
Once you’re reading time correctly, you can start using it for real-world automation.
1. Time-based conditions with T_COMP
The T_COMP instruction lets you compare date and time values (DT, DTL, TOD, etc.) directly, without messy manual logic.
Example use cases:
- Turn on night mode between 22:00 and 06:00
- Trigger a daily report at 23:59
- Raise a bit when maintenance is due after a certain calendar date
2. Time-of-day interrupts
For precise, once-per-day or once-per-shift tasks, use time-of-day interrupts:
- Configure a time-of-day interrupt in the CPU
- Link it to an OB (e.g.
OB10) - Put your “run at 06:00” logic in that OB
This keeps OB1 clean and guarantees your logic runs exactly when scheduled.
Synchronising the PLC Clock
For serious logging and traceability, it’s smart to synchronise the PLC time automatically:
- Use NTP (Network Time Protocol) if available on your network
- Otherwise, periodically sync from a central SCADA or time server via
WR_SYS_T - Avoid random manual changes by operators – they’ll break your audit trail
Even if you only log to CSV or a small database now, having correct time from day one saves a lot of pain when you add MES, OEE or historian systems later.
Common Mistakes With Date & Time in TIA Portal
Here are issues I see again and again on real projects:
- Mixing DATE_AND_TIME and DTL randomly across blocks
- Comparing plain integers instead of using T_COMP or proper time types
- Forgetting that system time vs local time are different and then being confused when logs look “offset”
- Not documenting the strategy: is everything UTC, or everything local?
Take a couple of minutes to decide on a clear approach and stick to it across the project.
Watch the Tutorial and Reuse the Project
The YouTube video walks through:
- Creating the DB with DTL tags
- Wiring RD_SYS_T / RD_LOC_T and checking live values
- Building simple time-based logic
- Tips for deploying this on real hardware with PLCSIM and TIA Portal
👉 Watch it now: https://www.youtube.com/watch?v=FzSZf3SvCOQ

