Question about RTC_S (Read system clock)

Hello all, A question… I use the “RTC_S” function block to write the current date and time to a string. The output off this block gives me the UTC time, where it should be UTC+2. I have managed to sync the linux clock with an ntp server and changed the time zone to CEST (UTC+2). The system time is correct. (i can see this on the information screen of the rfc 4072s and via putty) Still the output off the RTC_S remains UTC +0. Can someone explain to me what the problem is or tell me how to solve this small problem? thanks for your cooperation. Pieter

Hi Pieter, I’m not sure why the RTC_S function is only returning UTC+0 (this may be by design), but perhaps you could try the PBCL_DateTimeGet* function blocks in the PLCnextBase library, available from the PLCnext Store? I prefer the output of the PLCnextBase functions, but I don’t know if these functions have the same problem as RTC_S. Perhaps you could give these a try and let us know if they suit your application? - Martin.

Hi Martin, thanks alot for your answer. after installing the library i tried the “PBCL_DateTimeGet_1” function block. This function block also gives the UTC +0 time. I will have to look for another solution. this is what i am trying to do: In node red i get the sunset and sundown times on daily basis. These times are based on latitude and longitude (in our case UTC+2). comparing these times with the system time several actions get done. so the problem is: system time = UTC+0 / sunset-sunrise = UTC+2. We can write software to take the difference in account but is there a standard solution? thank you. Pieter

Hi Pieter, I hope that you do not need to do your own time shifting. I have raised this as an issue with the developers of the Base Library and I will let you know when they reply. - Martin.

OK, thank you Martin.

Hi Martin, Do you have an update about this question. thank you, Pieter

Hi Pieter, Sorry for the delay, the developer has just told me he didn’t get the issue I raised on the relevant Gitlab project. It seems that all the time functions currently available in PLCnext Engineer are returning the equivalent of “date -u”, while (if I understand correctly) you need “date”. Until this situation changes, the only solution I can think of is to write a PLCnext C++ component that basically does the same as the existing time functions, but calls “date” instead of “date -u”, and so returns the correct system time. Is this a possibility for you? Martin.

I think the problem can come from the fact that he has 2 clocks (hard and soft). the system (os) creates a clock that works with the CPU frequency and adjusts the time zone.

The disadvantage is that often this clock drift, but there is a way of sync to the hard clock (when reboot for example)
You should make sure that clock is used by the block function.
I hope it can help you.

It’s 2024. It’s been 5 years, I have PLCNext engineer 2024.0, but I have the exact same problem.

I am using the “RTC_S” function block to write the current date and time to a string. The output of this block gives me the time UTC+0 when it should be UTC+3. The time that I set inside the controller is UTC+3. In the meantime, the documentation for this block states that the time zone is being added (https://engineer.plcnext.help/2024.0_LTS_en/_index.htm).
When will this be fixed? 5 years have passed… :pensive_face:
image_2024-02-07_11-22-54.pngimage_2024-02-07_11-41-23.pngimage_2024-02-07_11-39-12.pngimage_2024-02-07_11-38-42.png