// this code prints out time and date from NTP servers
// source: http://www.esp8266.com/viewtopic.php?f=5&t=10094
//
// Somehow, this works without needing ssid and password!!
//
#include <ESP8266WiFi.h>
#include <time.h>
struct tm* tmStrc;
void setup() {
Serial.begin(115200); Serial.println();
WiFi.waitForConnectResult();
configTime(-8 * 3600, 0, "pool.ntp.org", "time.nist.gov");
// 0 * 3600 appears to give time in UTC.
// currently, Alaska time is 8 hrs behind UTC, and
// -8 * 3600 gives correct Alaska time as of Aug 2016 (DST).
// DST starts mid-March, ends early November
}
void loop() {
time_t t = time(NULL);
Serial.println(ctime(&t));
// first time thru, this prints:
// Thu Jan 1 00:00:00 1970
// next loop, correct date/time prints:
// Fri Aug 26 16:06:13 2016
tmStrc = localtime (&t);
Serial.println(tmStrc->tm_mday);
Serial.println((tmStrc->tm_mon)+1);
Serial.println((tmStrc->tm_year)+1900);
// more info on the tm struct here
// http://en.cppreference.com/w/c/chrono/tm
delay(30000);
}
Moderator: igrr
Yes, you are correct. SSID and password (as well as Wi-Fi mode) are saved in flash. Ref. new documentation https://github.com/esp8266/Arduino/blob ... md#station
Krzysztof