{"id":"iec-rtc","model_id":"RTC","name":"RTC","summary":"RTC is a function block that calculates elapsed time since a given start time. On a rising edge of EN, CDT is set to PDT and starts increasing; on a falling edge, CDT is set to DT#1970-01-01-00:00:00. It can also return the current date and time by setting PDT to the current local time on the rising edge of EN.","study_notes":["With PDT set to DT#1970-01-01-00:00:00 or left unconnected, RTC can be used as an operation hour counter.","To return the current date and time, set PDT to the current local time on the rising edge of EN."],"safety_notes":["The counter overflows on 7 February 2106."],"sources":[{"url":"https://content.helpme-codesys.com/en/libs/Standard/Current/Miscellaneous/RTC.html","title":"CODESYS Group","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":15,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"structured_text","code":"RTC","group":"Function block","syntax":"RTC(EN:=VarBOOL1, PDT:=DT#2006-03-30-14:00:00, Q=>VarBOOL2, CDT=>VarTimeCur);","parameters":[{"name":"EN","data_type":"BOOL","description":"Rising edge: CDT is set to PDT and CDT starts increasing. Falling edge: CDT is set to DT#1970-01-01-00:00:00."},{"name":"PDT","data_type":"DT","description":"Preset date and time"},{"name":"Q","data_type":"BOOL","description":"TRUE as long as CDT is counting"},{"name":"CDT","data_type":"DT","description":"Date and time, elapsed since PDT"}],"dialect":"","related":[],"standards":[]},"url":"https://machineschema.com/instruction/iec-rtc","license":"https://creativecommons.org/licenses/by/4.0/"}