You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/python/concepts/time-module/terms/asctime/asctime.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,43 +1,40 @@
1
1
---
2
2
Title: 'asctime()'
3
-
Description: 'Converts a time tuple or struct_time to a 24‑character human‑readable string.'
3
+
Description: 'Converts a time tuple or `struct_time` to a 24‑character human‑readable string.'
4
4
Subjects:
5
5
- 'Computer Science'
6
6
- 'Data Science'
7
7
Tags:
8
8
- 'Functions'
9
9
- 'Methods'
10
-
- 'Time'
11
10
- 'Python'
11
+
- 'Time'
12
12
CatalogContent:
13
13
- 'learn-python-3'
14
14
- 'paths/computer-science'
15
15
---
16
16
17
-
The **`time.asctime()`** Python function converts a time value (a 9‑element tuple or `time.struct_time`) into a readable, 24‑character string like`'Wed Sep 17 19:40:37 2025'`.
17
+
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'`.
18
18
19
19
## Syntax of `time.asctime()`
20
20
21
-
```py
21
+
```pseudo
22
22
import time
23
23
24
24
time.asctime(t)
25
-
time.asctime() # it uses current local time
26
25
```
27
26
28
27
**Parameters:**
29
28
30
29
-`t` (optional): A 9‑tuple or `time.struct_time` representing a UTC or local time, with fields `(year, month, mday, hour, min, sec, wday, yday, isdst)` as produced by `time.localtime()` or `time.gmtime()`.
30
+
- If omitted, `time.asctime()` uses `time.localtime()`.
31
+
-`wday` (weekday) and `yday` (day of year) are ignored.
32
+
-`isdst` may be `-1`, `0`, or `1`.
31
33
32
34
**Return value:**
33
35
34
36
-`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'`).
35
37
36
-
Notes:
37
-
38
-
- If `t` is omitted, `time.asctime()` uses `time.localtime()`.
39
-
-`wday` (weekday) and `yday` (day of year) are ignored; `isdst` may be `-1`, `0`, or `1`.
40
-
41
38
## Example
42
39
43
40
Convert the current local time (from `localtime()`) and show the default call with no arguments:
@@ -61,6 +58,8 @@ Current local time represented in string: Wed Sep 17 19:40:37 2025
61
58
Wed Sep 17 19:40:37 2025
62
59
```
63
60
61
+
> **Note:** The exact output will vary depending on when the function is run.
62
+
64
63
## Codebyte
65
64
66
65
Run this to see `time.asctime()` in action with local time, a UTC `struct_time`, and a custom tuple:
@@ -74,5 +73,5 @@ print("Current local time:", time.asctime())
0 commit comments