Error while extracting day, month and Year from epoch time

hi all,
i need to extract day,month and year from an epoch time. I'm using TimeLib.h

epoch i got was: 1539525927

and the simple sketch is:

time_t utcCalc = epoch;
Serial.print( day(utcCalc )); Serial.print( month(utcCalc )); Serial.println( year(utcCalc ) );

executing the code i receive the following string on debug console:


that means 28/09/2018 unfortunately today is 14/10/2018!!!

Just to be sure i check the epoch with an online epoch converter and the answer was:

Convert epoch to human readable date and vice versa

1539525927 Timestamp to Human date [batch convert timestamps to human dates]
GMT: Sunday 14 October 2018 14:05:27
Your time zone: domenica 14 ottobre 2018 16:05:27 GMT+02:00 DST
Relative: 7 minutes ago

that means epoch is correct!

i'm thinking about a bug with TimeLib conversion ... any other idea?

thank you very much!!

When I send the string "T1539525927" to the TimeSerial example of the Time library, it starts the clock at:

14:05:27 14 10 2018

Similarly, if I change the display code to:

void digitalClockDisplay(){
  // digital clock display of the time
  Serial.print(" ");
  Serial.print(" ");
  Serial.print(" ");

It repeatedly displays:
14:05:27 14 10 2018

Perhaps you have a mistake in the part of the code you aren't showing?

More here >:(

Without seeing the rest of your sketch it will be impossible to determine what the problem is. Even if you were foolish enough to make 'epoch' a float instead of unsigned long you would only be off by a few minutes:

float epoch = 1539525927;
epoch = 1539525888.00
(time_t)epoch = 1539525888

14:04:48 14/10/2018