Python asctime()
Published Oct 30, 2025
Contribute to Docs
The time.asctime() Python function converts a time value (a 9‑element tuple or time.struct_time) into a readable, 24‑character string such as 'Wed Sep 17 19:40:37 2025'.
Syntax of time.asctime()
import time
time.asctime(t)
Parameters:
t(optional): A 9‑tuple ortime.struct_timerepresenting a UTC or local time, with fields(year, month, mday, hour, min, sec, wday, yday, isdst)as produced bytime.localtime()ortime.gmtime().- If omitted,
time.asctime()usestime.localtime(). wday(weekday) andyday(day of year) are ignored.isdstmay be-1,0, or1.
- If omitted,
Return value:
str: A 24‑character string of the form'Sun Jun 20 23:21:05 1993'. The day of month is two characters wide and space‑padded if needed (e.g.,'Wed Sep 17 19:40:37 2025').
Example
Convert the current local time (from localtime()) and show the default call with no arguments:
import time# Using localtime() with asctime()t = time.localtime()lc = time.asctime(t)print("Current local time represented in string:", lc)# Default call (formats current local time)print(time.asctime())
Example output:
Current local time represented in string: Wed Sep 17 19:40:37 2025Wed Sep 17 19:40:37 2025
Note: The exact output will vary depending on when the function is run.
Codebyte
Run this to see time.asctime() in action with local time, a UTC struct_time, and a custom tuple:
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
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours