Wrong days against web sites

Hello, I am playing with ds3231 and the library from Adafruit, in the examples for ds3231 shows days since 1/1/1970, if I go online and check the days from 1/1/1970 to now they are very different, almost 400 days difference. Is there a reason for this?
The seconds since 1/1/ 1970 is correct but calculation of the day isn't. Is there a reason for that?

Serial.print(" since midnight 1/1/1970 = ");
    Serial.print(now.unixtime());
    Serial.print("s = ");
    Serial.print(now.unixtime() / 86400L);
    Serial.println("d");
1 Like

The site you used for days-since-epoch is incorrect.

1 Like

Bear in mind that unsigned / signed division can be problematic.

1 Like

What should be used instead of this code?

Just add a U...

now.unixtime() / 86400UL

What numbers are you getting? What numbers do you expect to get?
What Web site are you using?
Have you tried calculating the number of days yourself, using a calendar and a calculator? What number do you get?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.