← All notes

time: epoch-based clocks, struct_time, and sleep

Answer: This module provides various time-related functions. Although this module is always available, not all functions are available on all platforms. The epoch is the point where the time starts. On all platforms, that instant is January 1, 1970, 00:00:00 (UTC).

Epoch and portability

time collects various time-related functions. For related functionality, see also the datetime and calendar modules.

The module itself is always available, but not all functions are available on all platforms.

The epoch is the point where the time starts, and it is also the return value of time.gmtime(0).

On all platforms, that instant is January 1, 1970, 00:00:00 (UTC).

The term seconds since the epoch refers to elapsed seconds since the epoch.

Leap seconds are excluded from this total on all POSIX-compliant platforms.

sleep

time.sleep(seconds) will suspend execution of the calling thread for the given number of seconds.

A non-integer argument is allowed when you need a more precise sleep time.

The source documentation

The library source documentation also says not all functions are available on all platforms.

It also defines the epoch as the point where the time starts, matching time.gmtime(0), which is January 1, 1970, 00:00:00 UTC everywhere.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, time — Time access and conversions; CPython, time module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, time — Time access and conversions; CPython, time module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:cb74ptf6

iinventedlight. 2026. "time: epoch-based clocks, struct_time, and sleep." iinventedlight Library, iil:note:cb74ptf6, version of 2026-11-23. https://iinventedlight.com/library/notes/python-time/. License: CC-BY-4.0.

@misc{iil_note_cb74ptf6,
  author = {{iinventedlight}},
  title = {{time: epoch-based clocks, struct\_time, and sleep}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-time/},
  note = {Permanent ID iil:note:cb74ptf6. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-time.md.