time — time and timing related functions

The time module is a strict subset of the CPython time module. So, code written in MicroPython will work in CPython but not necessarily the other way around.

time.monotonic()

Returns an always increasing value of time with an unknown reference point. Only use it to compare against other values from monotonic.

Returns:the current monotonic time
Return type:float
time.sleep(seconds)

Sleep for a given number of seconds.

Parameters:seconds (float) – the time to sleep in fractional seconds
class time.struct_time((tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst))

Structure used to capture a date and time. Note that it takes a tuple!

Parameters:
  • tm_year (int) – the year, 2017 for example
  • tm_mon (int) – the month, range [1, 12]
  • tm_mday (int) – the day of the month, range [1, 31]
  • tm_hour (int) – the hour, range [0, 23]
  • tm_min (int) – the minute, range [0, 59]
  • tm_sec (int) – the second, range [0, 61]
  • tm_wday (int) – the day of the week, range [0, 6], Monday is 0
  • tm_yday (int) – the day of the year, range [1, 366], -1 indicates not known
  • tm_isdst (int) – 1 when in daylight savings, 0 when not, -1 if unknown.