#include <Arduino.h>
#include <WiFi.h>
// --- European Timezones ---
const char* TZ_BERLIN = "CET-1CEST,M3.5.0/2:00,M10.5.0/3:00"; // Central European Time (UTC+1/+2)
const char* TZ_LONDON = "GMT0BST,M3.5.0/1:00,M10.5.0/2:00"; // Greenwich Mean Time (UTC+0/+1)
const char* TZ_MOSCOW = "MSK-3"; // Moscow Standard Time (UTC+3, No DST)
const char* TZ_PARIS = "CET-1CEST,M3.5.0/2:00,M10.5.0/3:00"; // Central European Time (UTC+1/+2)
// --- North American Timezones ---
const char* TZ_NEW_YORK = "EST5EDT,M3.2.0/2:00,M11.1.0/2:00"; // Eastern Time (UTC-5/-4)
const char* TZ_CHICAGO = "CST6CDT,M3.2.0/2:00,M11.1.0/2:00"; // Central Time (UTC-6/-5)
const char* TZ_LOS_ANGELES = "PST8PDT,M3.2.0/2:00,M11.1.0/2:00"; // Pacific Time (UTC-8/-7)
const char* TZ_PHOENIX = "MST7"; // Mountain Time (UTC-7, No DST)
// --- Asian / Oceania Timezones ---
const char* TZ_SINGAPORE = "SGT-8"; // Singapore Time (UTC+8, No DST)
const char* TZ_BEIJING = "CST-8"; // China Standard Time (UTC+8, No DST)
const char* TZ_TOKYO = "JST-9"; // Japan Standard Time (UTC+9, No DST)
const char* TZ_NEW_DELHI = "IST-5:30"; // Indian Standard Time (UTC+5:30, No DST)
const char* TZ_SYDNEY = "AEST-10AEDT,M10.1.0/2:00,M4.1.0/3:00"; // Australian Eastern Time with DST
// --- Africa / South America Timezones ---
const char* TZ_JOHANNESBURG = "SAST-2"; // South Africa Standard Time (UTC+2, No DST)
const char* TZ_BUENOS_AIRES = "ART3"; // Argentina Time (UTC-3, No DST)
// choose your timezone here:
const char* TIMEZONE = TZ_BERLIN;
const char* NTPSERVER = "pool.ntp.org";
void setupWiFi() {
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println("connected");
Serial.println(WiFi.localIP());
}
void setupNTP() {
configTzTime(TIMEZONE, NTPSERVER);
}
void setup() {
Serial.begin(115200);
setupWiFi();
setupNTP();
}
void printTime() {
static time_t last_now;
time_t now;
time(&now);
if (last_now == now) return;
last_now = now;
Serial.printf("UTC Timestamp: %d - " , now);
Serial.print(ctime(&now));
}
void loop() {
printTime();
delay(10); // this speeds up the simulation
}