I stripped your code to show only the relevant parts for the time functionality. Unfortunately I don't get your intention behind setting esp in APmode AND configuring softAPmode. Then you set the IP etc, later print it over serial as if it were variable and indistinct. But I cant find where you you log on to your WiFi to be able to reach the internet...
My modified example just logs on to your WiFi and the esp will be reachable under its given (hardcoded) IP.
If it was your intention to have the esp span its own WiFi to be reachable for everyone, it would need some more modification.
#include <sys/time.h> // struct timeval
#include <time.h> // time() ctime()
#include <ESP8266WiFi.h> //Part of ESP8266 Board Manager install
#define NTP0 "us.pool.ntp.org"
#define NTP1 "time.nist.gov"
/*
Found this reference on setting TZ: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
Here are some example TZ values, including the appropriate Daylight Saving Time and its dates of applicability. In North American Eastern Standard Time (EST) and Eastern Daylight Time (EDT), the normal offset from UTC is 5 hours; since this is west of the prime meridian, the sign is positive. Summer time begins on March’s second Sunday at 2:00am, and ends on November’s first Sunday at 2:00am.
*/
#define TZ "EST+5EDT,M3.2.0/2,M11.1.0/2"
// Replace with your network details
const char* ssid = "yourSSID";
const char* password = "yourPASSPHRASE";
//setting the addresses
IPAddress staticIP(10, 0, 0, 174);
IPAddress gateway(10, 0, 0, 1);
IPAddress subnet(255, 255, 255, 0);
int DOW, MONTH, DATE, YEAR, HOUR, MINUTE, SECOND;
int lc = 0;
time_t tnow;
char strftime_buf[64];
void setup(void)
{
Serial.begin(74880);
if (Serial.available())
{
Serial.println("Starting...");
Serial.print("NTP_Observations.ino");
Serial.print("\n");
}
// set up TimeZone in local environment
setenv("TZ", TZ, 3);
tzset();
// Connecting to local WiFi network
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.config(staticIP, gateway, subnet);
WiFi.begin(ssid,password);
delay(10);
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(100);
}
configTime(0, 0, NTP0, NTP1);
Serial.println("\n WiFi connected");
Serial.print("MAC: ");
Serial.println(WiFi.macAddress());
Serial.print("Server IP: ");
Serial.println(WiFi.localIP());
Serial.println("\n");
Serial.print("wait for first valid timestamp ");
while (time(nullptr) < 100000ul)
{
Serial.print(".");
delay(10);
}
Serial.println(" time synced");
// set up SoftAP
// WiFi.softAP("DATA","*logger#");
// WiFi.softAPConfig(local_ip, gateway, subnet);
}
void loop()
{
getDateTime();
Serial.println(strftime_buf);
Serial.println("");
Serial.print(DOW);
Serial.println(" Day of week");
Serial.print(HOUR);
Serial.println(" Hours");
Serial.print(MINUTE);
Serial.println(" Minutes");
Serial.print(SECOND);
Serial.println(" Seconds");
Serial.println("\n");
delay(1000);
}
void getDateTime()
{
struct tm *ti;
tnow = time(nullptr) + 1;
strftime(strftime_buf, sizeof(strftime_buf), "%c", localtime(&tnow));
ti = localtime(&tnow);
DOW = ti->tm_wday;
YEAR = ti->tm_year + 1900;
MONTH = ti->tm_mon + 1;
DATE = ti->tm_mday;
HOUR = ti->tm_hour;
MINUTE = ti->tm_min;
SECOND = ti->tm_sec;
}