# LGF_GetClockState (FB / 1.0.0)

Overview

Author: Simatic Systems Support

## Short description

This function reads the local time, the system time and returns the NTP status.

### Block Interface

| LGF_GetClockState (FB) |
--- | --- | ---
|  |  |  |  | localTime |  |  | DTL
|  |  |  |  | systemTime |  |  | DTL
|  |  |  |  | isDaylightSavingTime |  |  | Bool
|  |  |  |  | ntpActivated |  |  | Bool
|  |  |  |  | error |  |  | Bool
|  |  |  |  | status |  |  | Word
|  |  |  |  | diagnostics |  |  | LGF_typeDiagnostics

### Output parameter

Identifier | Data type | Description
--- | --- | ---
localTime | DTL | Local time
systemTime | DTL | System time (UTC)
isDaylightSavingTime | Bool | Daylight saving time active
ntpActivated | Bool | NTP Client activated
error | Bool | TRUE: An error occurred during the execution of the FB
status | Word | 16#0000 - 16#7FFF: Status of the FB, 16#8000 - 16#FFFF: Error identification
diagnostics | LGF_typeDiagnostics | Diagnostics information of FB

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_FINISHED_NO_ERROR NO error occurred in function call
16#8401 | ERR_NTP_SERVER_SYNC_MISSING Error: NTP Client missing time synchronization
16#8601 | ERR_READ_LOCAL_TIME Error: Read local time
16#8602 | ERR_READ_SYSTEM_TIME Error: Read system time
16#8610 | ERR_READ_CLOCK_STATE Error: Read clock state

## User defined datatype(s)

### LGF_typeDiagnostics (UDT / V1.0.1)

Diagnostic structure to store and transfer diagnostic information from blocks through the interface.

Identifier | Data type | Default value | Description
--- | --- | --- | ---
status | Word | 16#0000 | Status of the Block or error identification when error occurred
subfunctionStatus | Word | 16#0000 | Status or return value of called FB's, FC's and system blocks
stateNumber | DInt | 0 | State in the state machine of the block where the error occurred

## Functional description

NOTE
  If NTP time synchronization is activated in the hardware configuration, make sure that the time zone settings are correctly set to your local time zone!

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Simatic Systems Support
| 06.05.2025 | First released version