Python Glossary Русский

all Python 3timefunction

time.ctime()

time conversion

Converts seconds since the epoch to a string like 'Sun Jun 20 23:21:05 1993' in local time; equivalent to asctime(localtime(s)).

Syntax

time.ctime([secs])

The time is local, so ctime(0) in Moscow is 03:00, not midnight. Despite the name, it has nothing to do with a file's ctime (os.path.getctime — metadata change time, creation time on Windows), though it is a handy way to show a getctime() result readably. As with asctime(), the format is fixed and English.

Examples

import time
print(time.ctime(0))  # → ? Thu Jan  1 03:00:00 1970 — в поясе UTC+3
print(time.ctime(0) == time.asctime(time.localtime(0)))  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy