.ctime()
Anonymous contributor
Published Apr 19, 2022
Contribute to Docs
The ctime()
function takes a time, expressed in seconds since the epoch, and returns a formatted string.
Syntax
ctime(s)
The argument s
is the number of seconds since the epoch. The epoch is defined as January 1, 1970, 00:00:00 UTC. If no argument is provided the function will use the current local time.
Example
The ctime()
function can be used to translate a time in seconds (from the epoch) into a human-readable format:
import timeprint(time.ctime(10000))# Output: Thu Jan 1 02:46:40 1970
Codebyte Example
The ctime()
function can be used to return the current local time.
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