#include <Arduino.h>
#include <NTPClient.h>
#include <tinyUDP.h>
int time_offset;
const char *TIME_OFFSET = "Texas";
String date_in;
String time_of_day;
String my_hour;
String my_minute;
String my_second;
tinyUDP ntpUDP;
NTPClient timeClient(ntpUDP, "0.pool.ntp.org");
/*
void getTime() {
if ( TIME_OFFSET == "Texas" ){
time_offset = -5 * 3600;
}
Serial.println(time_offset);
}
*/
void getTime(){
//if ( TIME_OFFSET == "Texas" ){
// time_offset = -5 * 3600;
//}
//timeClient.setTimeOffset(time_offset);
while (!timeClient.update()) {
timeClient.forceUpdate();
date_in = timeClient.getFormattedTime();
my_hour = timeClient.getHours();
my_minute = timeClient.getMinutes();
my_second = timeClient.getSeconds();
timeClient.getDay();
}
Serial.println(date_in);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
getTime();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}