cancel
Showing results for 
Search instead for 
Did you mean: 

RTC to Coordinated Universal Time (UTC)

inouee
Associate II

Hello everyone, I am using an STM32U575RG, and I would like to know if anyone can help me understand or show me how to use the RTC and convert it to Coordinated Universal Time (UTC).

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

Hello @inouee

Make sure to enable the RTC Clock, initialize the RTC with the current time and date, configure correctly (LSE, LSI, or HSE) and configure the prescaler to obtain the RTC clock. 

To convert to Coordinated Universal Time (UTC), you need to use the standard C-library functions in <time. h> to convert the time and date. Then, adjust the local time to get the UTC time. (Add or subtract X hours from the time to convert.). For example, if your local time zone is UTC+2 hours, subtract 2 hours from the RTC time to convert it to UTC. If daylight saving time applies, adjust accordingly.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

1 REPLY 1
Imen.D
ST Employee

Hello @inouee

Make sure to enable the RTC Clock, initialize the RTC with the current time and date, configure correctly (LSE, LSI, or HSE) and configure the prescaler to obtain the RTC clock. 

To convert to Coordinated Universal Time (UTC), you need to use the standard C-library functions in <time. h> to convert the time and date. Then, adjust the local time to get the UTC time. (Add or subtract X hours from the time to convert.). For example, if your local time zone is UTC+2 hours, subtract 2 hours from the RTC time to convert it to UTC. If daylight saving time applies, adjust accordingly.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen