Open saifuhameed opened 2 years ago
You can update the current time manually through the offset:
// Setup
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
// Update
timeClient.setTimeOffset(currentEpoch - millis() / 1000);
The last part tries to compensate _lastUpdate
. It is the best solution I've found so far and it is not accurate. There should be an easier way to do this. Hopefully this library will get this feature.
In my application NTPClient is used to get time for logging and displaying IOT events. We expect device to display IOT data through local webserver even without internet. But there is a problem, event time will be wrong due to there is no internet. So I suggest to add a function to enable offline updating of date and time, so that it will give at least actual date and time with reduced accuracy. Offline updating can be done from a settings page of IOT application, user can update date and time on device startup. This feature can be easily accommodated by adding a function to update
_lastUpdate
and_currentEpoc
manually.