NTP

Get current time information through NTP server.


import ntptime


//Set up NTP server
//eg:
//ntp = ntptime.client(host='jp.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='sg.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='tw.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='hk.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='tw.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='hk.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='us.pool.ntp.org', timezone=8)
//ntp = ntptime.client(host='de.pool.ntp.org', timezone=8)

ntp = ntptime.client(host='cn.pool.ntp.org', timezone=8)

//Get the timestamp
ntp.getTimestamp()

//Format the date
ntp.formatDate('-')

//Format the time
ntp.formatTime('-')

//Format date & time
ntp.formatDatetime('-',':')

ntp.year()
ntp.month()
ntp.day()
ntp.hour()
ntp.minute()
ntp.second()
ntp.weekday()
On This Page