Time Module

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Apr 19, 2022
Contribute to Docs

Python has a built-in time module that can be used for time related tasks. This module utilizes a number of different standards and objects that may be unfamiliar such as:

  • The epoch refers to a reference point in time from which calculations can be made. It is designated as midnight on January 1, 1970.
  • There are functions that will return values formatted using Daylight Savings Time (DST).
  • There is a specific time data type called struct_time.

The following functions are provided by this module.

Time Module

.ctime()
Takes a time, expressed in seconds elapsed since the epoch, and returns a formatted string.
.sleep()
Suspends execution of the current thread for a given time.
.strftime()
Returns a time as a string based on one or more formatting codes.

All contributors

Looking to contribute?

Learn Python on Codecademy