time

This library extends the built-in MicroPython time module (opens in a new tab) to include time.strftime() (opens in a new tab).

strftime() is omitted from the built-in time module to conserve space.

Installation

Use mip via mpremote:

> mpremote mip install time

See Package management (opens in a new tab) for more details on using mip and mpremote.

Common uses

strftime() is used when using a logging Formatter Object (opens in a new tab) that employs asctime (opens in a new tab).

For example:

logging.Formatter('%(asctime)s | %(name)s | %(levelname)s - %(message)s')

The expected output might look like:

Tue Feb 17 09:42:58 2009 | MAIN | INFO - test

But if this time extension library isn't installed, asctime will always be None:

None | MAIN | INFO - test