Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document getEpochTime() #64

Closed
donpdonp opened this issue Feb 17, 2019 · 5 comments · Fixed by #76
Closed

Document getEpochTime() #64

donpdonp opened this issue Feb 17, 2019 · 5 comments · Fixed by #76

Comments

@donpdonp
Copy link

going through the readme and even the .h file I was at a loss as to why there was no date functionality. Only by going through the .cpp did I find getEpochTime() - arguably the most important function in the library! Having this in the README would help newcomers.

@MrTanoshii
Copy link

Epoch time as far as NTP is concerned, is the time in seconds since January 1st 1900.
I'm also hoping they add in the date functionality, there is already a pull request for it.

@jibin2706
Copy link

@MrTanoshii Is the offset considered in the getEpochTime()?

@MrTanoshii
Copy link

@jibin2706
Yes, if you have a look at NTPClient.h, you will notice #define SEVENZYYEARS 2208988800UL which is used in the NTPClient.cpp forceUpdate(). Note that "SEVENZYYEARS" is equivalent to 70 years.

So yes, the getEpochTime() returns time from Jan 1st 1970 (Jan 1st 1900 + the 70 years offset)

@jibin2706
Copy link

I was talking about the fourth parameter from
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000)
😄

@MrTanoshii
Copy link

;O getEpochTime() doesn't actually request make the NTP UDP request, it only returns the time since the last update. (That is you'll get an erroneous time if you didn't update() or forceupdate() before trying to getEpochTime())

The fourth parameter is actually the update interval not an offset.
If you're using update(), a new time request is not sent out if the current millis() since the last update is smaller than the update interval.
If you're using forceUpdate(), the update interval is completely ignored

tl;dr getEpochTime is only affected by the update interval if you are using update()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants