Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Arduino上设置中央时区的时间?_C++_Arduino_Esp8266_Arduino Esp8266_Arduino C++ - Fatal编程技术网

C++ 如何在Arduino上设置中央时区的时间?

C++ 如何在Arduino上设置中央时区的时间?,c++,arduino,esp8266,arduino-esp8266,arduino-c++,C++,Arduino,Esp8266,Arduino Esp8266,Arduino C++,我想知道如何将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

我想知道如何将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();

谢谢你指出这一点。我将我的问题更新为时钟->时间。很抱歉,
time()
是在esp8266上实现的,很高兴知道。我想configTime()就是这么做的?它将Arduino时钟与国家服务器同步。时区在TZ.h中定义:
configTime(TZ_America_Chicago,“pool.ntp.org”)