cancel
Showing results for 
Search instead for 
Did you mean: 

From time_t to RTC loaded:why does gmtime() function returns tm_hour 2 hours lesser than expected?

Diego Colombo
Associate III

Hello

1628027999 should mean 2021-08-03 23:59:59,at least from a website that does not claim to keep in account any time zone,so I guess(wrongly ??)that it is referred to 0° Longitude

rawtime= 1628027999;
gmtime_r(&rawtime_t, &my_tm_struct);

it returns correctly tm_year, tm_month,tm_day ,tm_min,tm_sec.

I notice that tm_hour is 21 ,instead of 23 as expected.

The only way I found to get what i figure as correct is to increase rawtime before calling function

rawtime + =7200;//seconds in 2 hours

It's me acting wrong or what else?

I did not add any longitude data.

Is my patch legit?

Thanks for answers,hints or reading.

PS anyway the purpose is to fill other kind of struct :

RTC_TimeTypeDef and RTC_DateTypeDef to load an RTC on a STM32Lxx device

1 REPLY 1

1628027999 is August 3, 2021 21:59:59 UTC.

JW