On this page
time.localtime
Prev: time.gmtime | Up: time | Next: time.mktime
Rel: time.asctime, time.clock_getres, time.clock_gettime, time.clock_gettime_ns
Ref: docs.python.org — time.localtime
Tags: #public #python3 #stdlib #time
Import
import time
from time import localtime
Signature & Overview
time.localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
tm_sec,tm_wday,tm_yday,tm_isdst) Convert seconds since the Epoch to a time tuple expressing local time.
Usage
import time
tm = time.localtime()
assert isinstance(tm, time.struct_time) and tm.tm_year >= 2020
Gotchas
- Depends on the host's local timezone and DST rules: Prefer
datetime.now().astimezone()when you need timezone offsets preserved.
REPL Inspect
from time import localtime
help(localtime)
Linked from
Related notes
- tuts/python3/stdlib_module/time/gmtime Linked here; links to this page; shared tags: #stdlib, #time
- tuts/python3/stdlib_module/time/mktime 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