我想弄清楚如何将 esp8266 板上的时间设置为中央时区。
我已经尝试了以下方法,但似乎没有什么不同。
configTime(-5*3600, 3600, "pool.ntp.org", "time.nist.gov");
time(&curr_time);
curr_tm = localtime(&curr_time);
char date_string[100];
char time_string[100];
char ampm_string[50];
char zone_string[50];
strftime(date_string, 50, "Today is %B %d, %Y", curr_tm);
strftime(time_string, 50, "Current time is %T", curr_tm);
你能告诉我我做错了什么或者推荐一个我可以用来实现这个目标的库吗?
谢谢!
最佳答案
我想通了。
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
setenv("TZ", "CST6CDT,M3.2.0/02:00:00,M11.1.0/02:00:00", 1);
tzset();
关于c++ - 如何在 Arduino 上将时间设置为中央时区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59039946/