Setting S7-1200 CPU System Time in TIA Portal: UTC, Local & NTP

David Krause11 min read
SiemensTIA PortalTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The S7-1200 CPU (for example CPU 1214C DC/DC/DC or DC/DC/Rly, firmware V4.x through V4.7) maintains two distinct clocks: System Time (UTC-referenced) and Local Time (timezone-adjusted with DST). Every datalog entry, security event, diagnostic buffer entry, and recipe timestamp is derived from these clocks. When the CPU is powered down without a battery-backed real-time clock option (such as the insertable Battery Board BB 1297 for the 1214C/1215C, or the maintenance-free supercapacitor on CPUs with FW V4.4+), the time-of-day clock loses power and the CPU restarts with the last value or 01:00:00 01/01/2010 UTC, depending on firmware behavior.

This article covers three production-ready methods to set and maintain the S7-1200 CPU time inside TIA Portal:

  1. Manual time setting via Online & Diagnostics > Functions > Set Time.
  2. Programmatic time setting and reading using RD_SYS_T, RD_LOC_T, WR_SYS_T, and WR_LOC_T.
  3. Network Time Protocol (NTP) synchronization to a local NTP server or SNTP server.

Siemens explicitly recommends NTP over manual time adjustment in modern TIA Portal releases: per the TIA Portal V20 Update 3 release notes, "Set the system time before commissioning the device. Do not set the system time manually. Instead, configure a connection to the NTP server." This is because manual time steps cause time jumps that corrupt datalog timestamps and trigger PLC/HMI communication lockouts when the two devices disagree by more than a few seconds.

Prerequisites

Requirement Specification
Engineering tool TIA Portal V15.1 or later (V17/V18/V19/V20 recommended); PLCSIM V17+ for offline simulation
CPU S7-1200 family, firmware V4.2 minimum for WR_SYS_T; V4.4 for NTP via PROFINET interface
Hardware clock backup BB 1297 battery board (6ES7297-0AX30-0XA0) for 1214C/1215C, or supercapacitor-backed CPUs for maintenance-free retention
Ethernet interface PROFINET port on the CPU (NTP method only); accessible subnet from PG/PC
Network infrastructure NTP/SNTP server reachable on UDP/123 (NTP method); managed switch or router for time distribution
PG/PC time source PC synchronized to a reliable time source; PG/PC and PLC project must use matching timezone
PLC program blocks Optional: a dedicated time-management FB (e.g., DB “TimeSync”) and a single-instance OB1 call site
Critical: The PG/PC operating system timezone and DST setting must match the project's configured UTC offset. A Windows PC set to (UTC-06:00) Central Time will push a local time into the PLC when you click “Take from PG/PC,” but the PLC stores System Time as UTC and Local Time as derived. Always verify the project properties under PLC properties > Time of day before commissioning.

Method 1 — Manual Time Setting via Online & Diagnostics

This is the fastest method for bench commissioning a standalone CPU without a network. It writes the time directly to the CPU's RTC during an online session.

  1. Connect the PG/PC to the S7-1200 PROFINET port and assign a compatible IP address in the same subnet (e.g., PC: 192.168.0.10/24, CPU: 192.168.0.1/24).
  2. In the TIA Portal project tree, select the S7-1200 CPU device (not the project root).
  3. Click Online > Go online (or press Ctrl+Alt+O). Confirm the target device fingerprint when prompted.
  4. Expand Online & Diagnostics in the project tree, then open Functions > Set time.
  5. The dialog displays two readouts:
    • Module time — the current PLC System Time (UTC, no DST).
    • PG/PC time — the current local time of the engineering workstation.
  6. Select the checkbox “Take from PG/PC”. This populates the read/write fields with the PG/PC's local time, which TIA Portal will convert to UTC when writing to the PLC.
  7. Click Apply. The dialog confirms “Time was set successfully.”
  8. Click Go offline (or leave the online session open for verification).

Field-proven caveat: if the PG/PC has no time zone set, or is set to UTC with DST enabled in the OS, the resulting PLC clock will be off by exactly the DST offset (typically ±1 hour). Verify by reading back RD_SYS_T immediately after “Apply”.

Method 2 — Programmatic Time Control with WR_SYS_T / RD_SYS_T

Use this method when the CPU must set its own time from an HMI screen, a barcode-scanned timestamp, or a backup PLC acting as a master clock. The Extended Instructions “Time of day” library provides the relevant blocks under Instructions > Extended instructions > Date and time-of-day.

Instruction Function Time domain Notes
RD_SYS_T (SFC 1 / FB) Read System Time UTC (DTL format) Source for “actual UTC” in datalogs
WR_SYS_T (SFC 0 / FB) Set System Time UTC (DTL format) CPU accepts input as UTC
RD_LOC_T (FB) Read Local Time Local (timezone + DST applied) Use when datalog should display wall-clock time
WR_LOC_T (FB) Set Local Time Local (timezone + DST applied) Internally converts to UTC before writing
SET_TIMEZONE (FB) Configure timezone rule N/A Required for RD_LOC_T to return correct offset

The DTL (Date and Time Long) data structure is 16 bytes:

TYPE DTL
STRUCT
  YEAR    : UINT;    // 1970..2554
  MONTH   : USINT;   // 1..12
  DAY     : USINT;   // 1..31
  HOUR    : USINT;   // 0..23
  MINUTE  : USINT;   // 0..59
  SECOND  : USINT;   // 0..59
  // bits 0..3 = nanoseconds / 100,  bits 4..7 = weekday (1=Sunday)
  NANOSEC : UDINT;
END_STRUCT
END_TYPE

Example FB: HMI-Driven Time Set

The following SCL snippet runs in OB1 and writes the HMI-supplied local time into the CPU system clock. The HMI tag HMI_TimeInput is a DTL populated by an HMI date/time picker.

FUNCTION_BLOCK "FB_TimeSync"
VAR
    // Edge-detection bits so we write only on rising edge
    SetTimeTrig : BOOL;
    SetTimeTrigOld : BOOL;
    // Status bits
    Busy : BOOL;
    Error : BOOL;
    Status : WORD;
END_VAR
BEGIN
    // Detect rising edge of HMI "Apply" button
    SetTimeTrig := "HMI_TimeInput.Apply" AND NOT SetTimeTrigOld;
    SetTimeTrigOld := "HMI_TimeInput.Apply";

    IF SetTimeTrig THEN
        // Apply timezone offset before writing. CONFIG.TZ_OFFSET is in minutes.
        // Local = UTC + TZ_OFFSET (+ DST if active).
        // For S7-1200, use WR_SYS_T with already-UTC DTL; the HMI block
        // "HMI_TimeInput.Value" is assumed to be in UTC after HMI configuration.
        WR_SYS_T(REQ := TRUE,
                 IN  := "HMI_TimeInput.Value",   // DTL, UTC
                 BUSY=> Busy,
                 DONE=> "DB_TimeSync.SetDone",
                 ERROR=> Error,
                 STATUS=> Status);
    END_IF;
END_FUNCTION_BLOCK

Reading UTC vs Local in the Datalog

The S7-1200 datalog writes a DTL stamp to every record. By default, the datalog uses System Time (UTC), which is why a CPU configured for Central Time (UTC-06:00) writes datalog entries that appear “6 hours ahead” when read in Excel from a workstation that auto-applies a local-time conversion. To store wall-clock local time instead:

  1. Configure the project timezone under CPU properties > Time of day > Local time zone.
  2. Set DST rules manually or select a predefined rule (Europe, US, etc.).
  3. In the datalog trigger block, populate the time stamp with RD_LOC_T output rather than RD_SYS_T.
Common pitfall: Calling WR_SYS_T with a DTL that contains a local-time value will silently push the local time into the UTC field. The PLC then interprets future RD_LOC_T calls with the configured offset, producing timestamps off by 2× the timezone offset. Always supply UTC to WR_SYS_T.

Method 3 — NTP / SNTP Synchronization (Recommended for Production)

NTP eliminates manual steps, survives power cycles, and keeps all devices (PLC, HMI, drives, switches) on a single coherent timeline. The S7-1200 CPU firmware supports NTP client mode starting at FW V4.4 and SNTP from V4.2.

  1. Open the device view of the S7-1200 CPU in TIA Portal.
  2. Select the CPU, then open Properties > Time synchronization (or General > Time of day depending on TIA Portal version).
  3. Enable “Synchronize CPU with NTP server”.
  4. Configure up to four NTP servers in priority order. Format: dotted IPv4 address or FQDN. Example: 192.168.0.250 for a Windows Server or Linux chrony/ntpd instance.
  5. Set the Update interval (default 10 s, production-recommended 60–600 s). Shorter intervals increase network traffic; longer intervals risk drift on loosely-clocked oscillators.
  6. Compile and download the hardware configuration.
  7. Verify in Online & Diagnostics > Diagnostics > Time: the “Last synchronization” timestamp must be within the configured interval of the current PLC time.

The CPU sends NTP requests from UDP/123 to each configured server and accepts the response with the best stratum. In a broadcast network, the CPU will also accept NTP broadcast frames if the corresponding option is enabled under the PROFINET interface properties.

Configuring Timezone and DST

Correct timezone/DST configuration is the single most common source of “5-hour offset” bugs reported on S7-1200 datalogs. Configure the rules before commissioning the time source.

Setting Location in TIA Portal Notes
Local timezone offset CPU properties > Time of day > Time zone Minutes east of UTC. US Central = -360
DST rule CPU properties > Time of day > Daylight saving Choose predefined rule or manual UTC offset
SET_TIMEZONE FB parameter Programmatic at startup Override of project setting at runtime

Example: a Houston-based machine running US Central Time:

TZ_OFFSET_MIN  := -360;   // UTC-06:00 standard time
DST_ACTIVE    := TRUE;
DST_OFFSET_MIN:= 60;     // +1 h during DST

After DST changes, the PLC applies the offset automatically. If the project was authored without a DST rule but the OS or NTP server observes DST, the HMI clocks will drift by exactly 60 minutes twice a year — always define DST explicitly.

Synchronizing HMI and Other Devices

The HMI (Comfort Panel, Unified Comfort Panel, or WinCC Runtime) maintains its own clock. To keep it aligned with the PLC:

  • Set the HMI's Time master to Slave: under HMI > Connections > Area Pointer > “Date/Time PLC”. The HMI then accepts time updates broadcast by the PLC.
  • Alternatively, configure the HMI as an NTP client to the same NTP server, achieving independent synchronization.
  • When the PLC time changes by more than a few seconds, the HMI may stop accepting connections — Siemens introduced this safeguard in WinCC V13 SP2 / TIA Portal V14 onward. Fix by ensuring both devices sync from the same NTP source rather than from each other.

Verification

  1. Online & Diagnostics > Functions > Set time: confirm the displayed Module time matches the expected value within ±1 s.
  2. In the user program, add a watch table with %DBTimeSync.SysTimeRead and force a cyclic read of RD_SYS_T. Verify the DTL fields YEAR, MONTH, DAY, HOUR, MINUTE, SECOND are correct.
  3. Trigger a single datalog record (e.g., a bit rising edge on the trigger tag) and open the resulting CSV in Excel. The leftmost timestamp column must match the expected UTC (or local) value, depending on configuration.
  4. For NTP, check the diagnostics buffer for entries 0xE401 (“Time synchronization error”) or 0xE402. A clean buffer after one full update interval confirms NTP health.

Troubleshooting Matrix

Symptom Root cause Resolution
Datalog CSV shows UTC 5–7 h ahead of operator time Datalog stamp uses RD_SYS_T but viewer expects local Either change viewer to UTC, or change datalog source to RD_LOC_T after configuring timezone/DST
“Time was set” dialog succeeds but HMI/webserver still shows wrong time HMI is configured as time master; PLC push is rejected Set HMI to Slave, or sync HMI independently via NTP
Time jumps backwards by 1 h twice per year DST rule missing or duplicated Configure explicit DST rule in CPU properties; avoid “Take from PG/PC” after a DST transition
CPU loses time on power cycle No battery / no supercap Install BB 1297 (1214C/1215C) or upgrade to firmware V4.4+ with maintenance-free clock
WR_SYS_T returns STATUS = 0x80C1 Invalid DTL (month=0, day=0, hour=25, etc.) Validate DTL before write; clamp values and reject non-finite inputs
NTP sync fails silently Firewall blocks UDP/123 or wrong IP family Open UDP/123 on the network path; verify IPv4 address, not IPv6
Date updates but time of day does not when “Take from PG/PC” PG/PC minutes and seconds already match PLC, TIA skips the write Uncheck “Take from PG/PC” and manually type the desired time, then Apply
PLCSIM and real CPU show different times PLCSIM uses host OS time; not a real RTC Disable PLCSIM time tests in commissioning; verify on hardware

Best Practices for Long-Term Reliability

  • Always prefer NTP over manual time setting on production machines. The TIA Portal V20 Update 3 documentation explicitly recommends NTP to avoid time-jump-induced datalog and audit-trail corruption.
  • Run a single NTP source per machine line; let it serve all PLCs, HMIs, drives, and the engineering station. This eliminates cross-device drift.
  • Store datalogs in UTC and convert to local time at the viewer (Excel, SCADA) using a known offset. Centralized time conversion simplifies DST handling.
  • If the cabinet has no network, embed a low-cost NTP appliance (e.g., a Raspberry Pi with GPS or a Meinberg LANTIME) instead of relying on operator time entry.
  • Add a startup HMI screen that auto-popups when the CPU detects an implausible year (< 2025) and forces the operator to set the clock. This is the simplest guard for battery-less installations.
  • Always set the PG/PC operating system timezone to the same region as the deployed machine. A mismatch produces a one-time offset that propagates into every datalog until re-flash.

Where do I set the CPU clock in TIA Portal?

Go online with the CPU, then open Online & Diagnostics > Functions > Set time. Enable “Take from PG/PC,” confirm the displayed PG/PC time matches your local time, and click Apply. The PLC system clock (UTC) updates immediately.

Why does my S7-1200 datalog show UTC time instead of local time?

The datalog header uses RD_SYS_T by default, which returns UTC. Either convert UTC to local time in your viewer, or change the datalog block to use RD_LOC_T after configuring the CPU's timezone and DST rule under CPU properties > Time of day.

How do I configure NTP on an S7-1200 CPU?

Open the device configuration, navigate to the CPU's Time of day or Time synchronization properties, enable NTP, and enter up to four NTP server IPv4 addresses. Compile and download the hardware configuration. Verify with Online & Diagnostics > Time.

What is the difference between RD_SYS_T and RD_LOC_T?

RD_SYS_T reads the CPU's UTC-based System Time. RD_LOC_T returns the Local Time derived from System Time plus the configured timezone offset and DST adjustment. Use RD_SYS_T for datalogs that must remain consistent across machines in different regions; use RD_LOC_T for human-readable display.

Does the S7-1200 keep time across a power cycle?

CPUs with firmware V4.4 or later use a maintenance-free supercapacitor and retain the clock for several days without power. Older firmware requires the BB 1297 battery board (6ES7297-0AX30-0XA0) on 1214C/1215C, or the time will reset to the firmware default on power loss.

Back to blog