Time.adjustTime()
adjustTime(long adjustment)
- 作用:
按不同时区改写当前时间
- 参数:
adjustment:按照时区转换成的秒数,例如:北京时区 8h*3600s/h=28800s
- 例子:
#include <TimeLib.h> Time time; void setup(){ Serial.begin(115200); time.setTime(15, 45, 00, 10, 7, 2017);//设置时间(2017年7月10日,15:45:00) time.adjustTime(8 * SECS_PER_HOUR);//时区转换成北京时间 } void loop(){ Serial.print(time.year()); Serial.print('/'); Serial.print(time.month()); Serial.print('/'); Serial.print(time.day()); Serial.print(' '); Serial.print(time.hour()); Serial.print(':'); Serial.print(time.minute()); Serial.print(':'); Serial.print(time.second()); Serial.println(); delay(1000); }