On this page
time.ctime
Prev: time.clock_settime_ns | Up: time | Next: time.get_clock_info
Rel: time.asctime, time.clock_getres, time.clock_gettime, time.clock_gettime_ns
Ref: docs.python.org — time.ctime
Tags: #public #python3 #stdlib #time
Import
import time
from time import ctime
Signature & Overview
time.ctime(seconds) -> string
Convert a time in seconds since the Epoch to a string in local time.
Usage
import time
s = time.ctime(0)
assert isinstance(s, str) and len(s) == 24
Gotchas
- Uses local timezone and omits the timezone name: Use
datetime.fromtimestamp(ts, timezone.utc).isoformat()for unambiguous logs.
REPL Inspect
from time import ctime
help(ctime)
Linked from
Related notes
- tuts/python3/stdlib_module/time/clock_settime_ns Linked here; links to this page; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/get_clock_info Linked here; links to this page; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/asctime Linked here; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/clock_getres Linked here; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/clock_gettime Linked here; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/clock_gettime_ns Linked here; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/time Linked here; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time links to this page; shared tags: #stdlib
- tuts/c/stdlib/time shared tags: #stdlib, #time
- tuts/c/stdlib/time/asctime shared tags: #stdlib, #time