Time Module
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
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Career path
Front-End Engineer
Front-end engineers work closely with designers to make websites beautiful, functional, and fast.Includes 34 CoursesWith Professional CertificationBeginner Friendly115 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours