Open links in new tab
  1. The time module in Python provides functions to work with time values, perform conversions, pause execution, and measure performance. It works with seconds since the epoch (January 1, 1970, UTC on most systems) and supports multiple representations like floats, struct_time, and formatted strings.

    Basic Usage

    import time

    # Current time in seconds since epoch
    secs = time.time()
    print("Seconds since epoch:", secs)

    # Human-readable local time
    print("Local time:", time.ctime(secs))

    # Pause execution for 2.5 seconds
    time.sleep(2.5)
    Copied!

    Working With struct_time

    struct_time is a named tuple returned by functions like gmtime() and localtime().

    # UTC time
    utc_obj = time.gmtime()
    print("UTC:", utc_obj.tm_year, utc_obj.tm_mon, utc_obj.tm_mday)

    # Local time
    local_obj = time.localtime()
    print("Local:", local_obj.tm_hour, local_obj.tm_min)
    Copied!

    Convert between formats:

    Feedback
  2. Python Time Module - GeeksforGeeks

    Jul 23, 2025 · In this article, we will discuss the time module and various functions provided by this module with the help of good examples. As the name suggests Python time module allows to work …

  3. time | Python Standard Library – Real Python

    The Python time module provides various time-related functions. It allows you to work with time in a variety of ways, including getting the current time, measuring …

  4. Python time Module - W3Schools

    The time module provides functions for working with time values and delays. Use it to measure elapsed time, add delays, format timestamps, or convert between time representations.

  5. Python time Module (with Examples) - Programiz

    Learn how to use the time module in Python to handle time-related tasks, such as getting the current time, formatting time, sleeping for a specified time, and more. See the synta…

    • In Python, the time()function returns the number of seconds passed since epoch (the point where time begins). For the Unix system, January 1, 1970, 00:00:00 at UTCis epoch. Let's see an example, In the ab…
    See more on programiz.com
  6. Python Time Functions - TechBeamers

    Nov 30, 2025 · Python Time & Datetime are the primary Python modules to program date and time. In this tutorial, we’ll explore the Python time module, will see …

  7. People also ask
    Loading
    Unable to load answer
  8. Python `time` Library: A Comprehensive Guide - CodeRivers

    Jan 24, 2025 · Learn how to use the time library in Python to work with time-related operations, such as getting the current time, measuring elapsed time, formatting time, and more. This blog post covers …

  9. How do I get the current time in Python? - Stack Overflow

    If you're displaying the time with Python for the user, ctime works nicely, not in a table (it doesn't typically sort well), but perhaps in a clock. However, I personally …

  10. 5 Best Ways to Access and Convert Time Using the …

    Mar 8, 2024 · Learn five methods to interact with time using Python's built-in time library. See examples of getting current time, converting timestamps, formatting …

  11. time – time related functions — MicroPython latest documentation

    time – time related functions This module implements a subset of the corresponding CPython module, as described below. For more information, refer to the original CPython documentation: time. The …