UIFlow Guide
Set different time zones and display the real-time clock on the serial monitor (year, month, day, hour, minute, second, weekday).
from m5stack import *
from m5stack_ui import *
from uiflow import *
import time
rtc.settime('ntp', host='cn.pool.ntp.org', tzone=8)
while True:
print(rtc.datetime()[0])
print(rtc.datetime()[1])
print(rtc.datetime()[2])
print(rtc.datetime()[3])
print(rtc.datetime()[4])
print(rtc.datetime()[5])
print(rtc.datetime()[6])
wait(1)
wait_ms(2)
rtc.settime('ntp', host='cn.pool.ntp.org', tzone=8)
Set the time through the NTP (Network Time Protocol) host server and adjust according to the time zone. You can choose the following NTP servers:
cn.pool.ntp.org: China NTP server
jp.pool.ntp.org: Japan NTP server
sg.pool.ntp.org: Singapore NTP server
tw.pool.ntp.org: Taiwan NTP server
hk.pool.ntp.org: Hong Kong NTP server
us.pool.ntp.org: United States NTP server
de.pool.ntp.org: Germany NTP server
cn.pool.ntp.org
to set the time and adjust according to the +8 hour time zone offset.str(rtc.datetime()[0])
str(rtc.datetime()[1])
str(rtc.datetime()[2])
str(rtc.datetime()[3])
str(rtc.datetime()[4])
str(rtc.datetime()[5])
str(rtc.datetime()[6])
rtc.datetime((0, 1, 1, 0, 0, 0, 0, 0))
str(rtc.datetime())
str(rtc.printRTCtime())