You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ezTime/examples/Timezones/Timezones.ino

44 lines
1.1 KiB

7 years ago
#include <ezTime.h>
#include <WiFi.h>
void setup() {
Serial.begin(115200);
while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
7 years ago
WiFi.begin("your-ssid", "your-password");
// Uncomment the line below to see what it does behind the scenes
// setDebug(INFO);
7 years ago
waitForSync();
7 years ago
Serial.println();
Serial.println("UTC: " + UTC.dateTime());
Timezone myTZ;
// Provide official timezone names
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
myTZ.setLocation(F("Pacific/Auckland"));
Serial.print(F("New Zealand: "));
Serial.println(myTZ.dateTime());
// Or country codes for countries that do not span multiple timezones
mtTZ.setLocation(F("de"));
Serial.print(F("Germany: "));
Serial.println(myTZ.dateTime());
// See if local time can be obtained (does not work in countries that span multiple timezones)
Serial.print(F("Local (GeoIP): "));
if (myTZ.setLocation()) {
Serial.println(myTZ.dateTime());
} else {
Serial.println(errorString());
}
7 years ago
}
void loop() {
events();
7 years ago
}