Skip to content

Commit 0708c65

Browse files
author
heuman-a
committed
Add UTC EpochTime function
1 parent 2233b91 commit 0708c65

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

NTPClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ unsigned long NTPClient::getEpochTime() const {
136136
((millis() - this->_lastUpdate) / 1000); // Time since last update
137137
}
138138

139+
unsigned long NTPClient::getUTCEpochTime() const {
140+
return this->_currentEpoc + // Epoch returned by the NTP server
141+
((millis() - this->_lastUpdate) / 1000); // Time since last update
142+
}
143+
139144
int NTPClient::getDay() const {
140145
return (((this->getEpochTime() / 86400L) + 4 ) % 7); //0 is Sunday
141146
}

NTPClient.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ class NTPClient {
107107
*/
108108
unsigned long getEpochTime() const;
109109

110+
/**
111+
* @return time in seconds since Jan. 1, 1970
112+
*/
113+
unsigned long getUTCEpochTime() const;
110114
/**
111115
* Stops the underlying UDP client
112116
*/

0 commit comments

Comments
 (0)