/
usr
/
share
/
doc
/
python3-docs
/
html
/
library
/
/usr/share/doc/python3-docs/html/library
mkdir
upload
Name
Size
Mode
Actions
2to3.html
61709
0644
edit
dl
rm
abc.html
41394
0644
edit
dl
rm
aifc.html
28114
0644
edit
dl
rm
allos.html
32236
0644
edit
dl
rm
archiving.html
11992
0644
edit
dl
rm
argparse.html
274984
0644
edit
dl
rm
array.html
33547
0644
edit
dl
rm
ast.html
39595
0644
edit
dl
rm
asynchat.html
32546
0644
edit
dl
rm
asyncio-dev.html
51869
0644
edit
dl
rm
asyncio-eventloop.html
111215
0644
edit
dl
rm
asyncio-eventloops.html
33026
0644
edit
dl
rm
asyncio-protocol.html
87431
0644
edit
dl
rm
asyncio-queue.html
23957
0644
edit
dl
rm
asyncio-stream.html
61005
0644
edit
dl
rm
asyncio-subprocess.html
58015
0644
edit
dl
rm
asyncio-sync.html
35678
0644
edit
dl
rm
asyncio-task.html
83968
0644
edit
dl
rm
asyncio.html
28026
0644
edit
dl
rm
asyncore.html
42706
0644
edit
dl
rm
atexit.html
18433
0644
edit
dl
rm
audioop.html
35442
0644
edit
dl
rm
base64.html
36454
0644
edit
dl
rm
bdb.html
43423
0644
edit
dl
rm
binary.html
12723
0644
edit
dl
rm
binascii.html
24745
0644
edit
dl
rm
binhex.html
11669
0644
edit
dl
rm
bisect.html
25602
0644
edit
dl
rm
builtins.html
11604
0644
edit
dl
rm
bz2.html
33358
0644
edit
dl
rm
calendar.html
39539
0644
edit
dl
rm
cgi.html
55881
0644
edit
dl
rm
cgitb.html
12765
0644
edit
dl
rm
chunk.html
16872
0644
edit
dl
rm
cmath.html
34171
0644
edit
dl
rm
cmd.html
43811
0644
edit
dl
rm
code.html
27886
0644
edit
dl
rm
codecs.html
134071
0644
edit
dl
rm
codeop.html
14304
0644
edit
dl
rm
collections.abc.html
60912
0644
edit
dl
rm
collections.html
154946
0644
edit
dl
rm
colorsys.html
12627
0644
edit
dl
rm
compileall.html
28263
0644
edit
dl
rm
concurrency.html
21203
0644
edit
dl
rm
concurrent.futures.html
60660
0644
edit
dl
rm
concurrent.html
7959
0644
edit
dl
rm
configparser.html
141052
0644
edit
dl
rm
constants.html
17500
0644
edit
dl
rm
contextlib.html
88801
0644
edit
dl
rm
copy.html
13841
0644
edit
dl
rm
copyreg.html
14725
0644
edit
dl
rm
crypt.html
20331
0644
edit
dl
rm
crypto.html
10914
0644
edit
dl
rm
csv.html
69043
0644
edit
dl
rm
ctypes.html
264529
0644
edit
dl
rm
curses.ascii.html
25197
0644
edit
dl
rm
curses.html
175551
0644
edit
dl
rm
curses.panel.html
16706
0644
edit
dl
rm
custominterp.html
8734
0644
edit
dl
rm
datatypes.html
23950
0644
edit
dl
rm
datetime.html
306435
0644
edit
dl
rm
dbm.html
43119
0644
edit
dl
rm
debug.html
13983
0644
edit
dl
rm
decimal.html
233486
0644
edit
dl
rm
development.html
25123
0644
edit
dl
rm
difflib.html
96156
0644
edit
dl
rm
dis.html
106191
0644
edit
dl
rm
distribution.html
10506
0644
edit
dl
rm
distutils.html
10884
0644
edit
dl
rm
doctest.html
179752
0644
edit
dl
rm
dummy_threading.html
9316
0644
edit
dl
rm
email.charset.html
26431
0644
edit
dl
rm
email.compat32-message.html
86150
0644
edit
dl
rm
email.contentmanager.html
30028
0644
edit
dl
rm
email.encoders.html
14250
0644
edit
dl
rm
email.errors.html
19704
0644
edit
dl
rm
email.examples.html
57872
0644
edit
dl
rm
email.generator.html
41798
0644
edit
dl
rm
email.header.html
31219
0644
edit
dl
rm
email.headerregistry.html
57670
0644
edit
dl
rm
email.html
27741
0644
edit
dl
rm
email.iterators.html
13532
0644
edit
dl
rm
email.message.html
87210
0644
edit
dl
rm
email.mime.html
36081
0644
edit
dl
rm
email.parser.html
47430
0644
edit
dl
rm
email.policy.html
75241
0644
edit
dl
rm
email.util.html
33853
0644
edit
dl
rm
ensurepip.html
18700
0644
edit
dl
rm
enum.html
133949
0644
edit
dl
rm
errno.html
41331
0644
edit
dl
rm
exceptions.html
85151
0644
edit
dl
rm
faulthandler.html
23396
0644
edit
dl
rm
fcntl.html
27321
0644
edit
dl
rm
filecmp.html
25036
0644
edit
dl
rm
fileformats.html
11129
0644
edit
dl
rm
fileinput.html
30030
0644
edit
dl
rm
filesys.html
13418
0644
edit
dl
rm
fnmatch.html
16987
0644
edit
dl
rm
formatter.html
37666
0644
edit
dl
rm
fpectl.html
17538
0644
edit
dl
rm
fractions.html
29918
0644
edit
dl
rm
frameworks.html
13471
0644
edit
dl
rm
ftplib.html
54429
0644
edit
dl
rm
functional.html
9002
0644
edit
dl
rm
functions.html
201486
0644
edit
dl
rm
functools.html
64951
0644
edit
dl
rm
gc.html
29524
0644
edit
dl
rm
getopt.html
25353
0644
edit
dl
rm
getpass.html
12061
0644
edit
dl
rm
gettext.html
76641
0644
edit
dl
rm
glob.html
18432
0644
edit
dl
rm
grp.html
12383
0644
edit
dl
rm
gzip.html
32669
0644
edit
dl
rm
hashlib.html
79554
0644
edit
dl
rm
heapq.html
35529
0644
edit
dl
rm
hmac.html
17827
0644
edit
dl
rm
html.entities.html
11361
0644
edit
dl
rm
html.html
11108
0644
edit
dl
rm
html.parser.html
41842
0644
edit
dl
rm
http.client.html
65250
0644
edit
dl
rm
http.cookiejar.html
96195
0644
edit
dl
rm
http.cookies.html
39329
0644
edit
dl
rm
http.html
37602
0644
edit
dl
rm
http.server.html
58191
0644
edit
dl
rm
i18n.html
10464
0644
edit
dl
rm
idle.html
48412
0644
edit
dl
rm
imaplib.html
67339
0644
edit
dl
rm
imghdr.html
13456
0644
edit
dl
rm
imp.html
48153
0644
edit
dl
rm
importlib.html
173109
0644
edit
dl
rm
index.html
67768
0644
edit
dl
rm
inspect.html
130355
0644
edit
dl
rm
internet.html
31087
0644
edit
dl
rm
intro.html
9904
0644
edit
dl
rm
io.html
122685
0644
edit
dl
rm
ipaddress.html
105873
0644
edit
dl
rm
ipc.html
33743
0644
edit
dl
rm
itertools.html
132824
0644
edit
dl
rm
json.html
81078
0644
edit
dl
rm
keyword.html
8918
0644
edit
dl
rm
language.html
13648
0644
edit
dl
rm
linecache.html
13492
0644
edit
dl
rm
locale.html
61540
0644
edit
dl
rm
logging.config.html
85489
0644
edit
dl
rm
logging.handlers.html
112397
0644
edit
dl
rm
logging.html
134850
0644
edit
dl
rm
lzma.html
56484
0644
edit
dl
rm
macpath.html
9257
0644
edit
dl
rm
mailbox.html
157315
0644
edit
dl
rm
mailcap.html
14676
0644
edit
dl
rm
markup.html
19356
0644
edit
dl
rm
marshal.html
18317
0644
edit
dl
rm
math.html
53661
0644
edit
dl
rm
mimetypes.html
31410
0644
edit
dl
rm
misc.html
8123
0644
edit
dl
rm
mm.html
10022
0644
edit
dl
rm
mmap.html
34294
0644
edit
dl
rm
modulefinder.html
18559
0644
edit
dl
rm
modules.html
10914
0644
edit
dl
rm
msilib.html
57205
0644
edit
dl
rm
msvcrt.html
21989
0644
edit
dl
rm
multiprocessing.html
365487
0644
edit
dl
rm
netdata.html
17470
0644
edit
dl
rm
netrc.html
14568
0644
edit
dl
rm
nis.html
11659
0644
edit
dl
rm
nntplib.html
69601
0644
edit
dl
rm
numbers.html
41432
0644
edit
dl
rm
numeric.html
15535
0644
edit
dl
rm
operator.html
81460
0644
edit
dl
rm
optparse.html
249942
0644
edit
dl
rm
os.html
398039
0644
edit
dl
rm
os.path.html
53818
0644
edit
dl
rm
ossaudiodev.html
47947
0644
edit
dl
rm
othergui.html
10256
0644
edit
dl
rm
parser.html
42408
0644
edit
dl
rm
pathlib.html
116726
0644
edit
dl
rm
pdb.html
52661
0644
edit
dl
rm
persistence.html
15281
0644
edit
dl
rm
pickle.html
115052
0644
edit
dl
rm
pickletools.html
17094
0644
edit
dl
rm
pipes.html
15991
0644
edit
dl
rm
pkgutil.html
31878
0644
edit
dl
rm
platform.html
33728
0644
edit
dl
rm
plistlib.html
29290
0644
edit
dl
rm
poplib.html
30940
0644
edit
dl
rm
posix.html
17608
0644
edit
dl
rm
pprint.html
41969
0644
edit
dl
rm
profile.html
71848
0644
edit
dl
rm
pty.html
17594
0644
edit
dl
rm
pwd.html
13098
0644
edit
dl
rm
pyclbr.html
16520
0644
edit
dl
rm
pydoc.html
15991
0644
edit
dl
rm
pyexpat.html
88938
0644
edit
dl
rm
python.html
17133
0644
edit
dl
rm
py_compile.html
15508
0644
edit
dl
rm
queue.html
28199
0644
edit
dl
rm
quopri.html
13858
0644
edit
dl
rm
random.html
60646
0644
edit
dl
rm
re.html
191176
0644
edit
dl
rm
readline.html
42133
0644
edit
dl
rm
reprlib.html
24964
0644
edit
dl
rm
resource.html
36552
0644
edit
dl
rm
rlcompleter.html
14392
0644
edit
dl
rm
runpy.html
26607
0644
edit
dl
rm
sched.html
20034
0644
edit
dl
rm
secrets.html
24734
0644
edit
dl
rm
select.html
62819
0644
edit
dl
rm
selectors.html
35845
0644
edit
dl
rm
shelve.html
28777
0644
edit
dl
rm
shlex.html
48979
0644
edit
dl
rm
shutil.html
74207
0644
edit
dl
rm
signal.html
55064
0644
edit
dl
rm
site.html
32242
0644
edit
dl
rm
smtpd.html
35892
0644
edit
dl
rm
smtplib.html
68433
0644
edit
dl
rm
sndhdr.html
12439
0644
edit
dl
rm
socket.html
196077
0644
edit
dl
rm
socketserver.html
81918
0644
edit
dl
rm
spwd.html
12328
0644
edit
dl
rm
sqlite3.html
161872
0644
edit
dl
rm
ssl.html
266327
0644
edit
dl
rm
stat.html
44722
0644
edit
dl
rm
statistics.html
50050
0644
edit
dl
rm
stdtypes.html
465658
0644
edit
dl
rm
string.html
95262
0644
edit
dl
rm
stringprep.html
18654
0644
edit
dl
rm
struct.html
51100
0644
edit
dl
rm
subprocess.html
141926
0644
edit
dl
rm
sunau.html
31757
0644
edit
dl
rm
superseded.html
13781
0644
edit
dl
rm
symbol.html
8848
0644
edit
dl
rm
symtable.html
26112
0644
edit
dl
rm
sys.html
141670
0644
edit
dl
rm
sysconfig.html
30259
0644
edit
dl
rm
syslog.html
21026
0644
edit
dl
rm
tabnanny.html
12269
0644
edit
dl
rm
tarfile.html
96758
0644
edit
dl
rm
telnetlib.html
30409
0644
edit
dl
rm
tempfile.html
41394
0644
edit
dl
rm
termios.html
18181
0644
edit
dl
rm
test.html
78555
0644
edit
dl
rm
text.html
13786
0644
edit
dl
rm
textwrap.html
37998
0644
edit
dl
rm
threading.html
103464
0644
edit
dl
rm
time.html
79629
0644
edit
dl
rm
timeit.html
45249
0644
edit
dl
rm
tk.html
23299
0644
edit
dl
rm
tkinter.html
82932
0644
edit
dl
rm
tkinter.scrolledtext.html
9957
0644
edit
dl
rm
tkinter.tix.html
51858
0644
edit
dl
rm
tkinter.ttk.html
110673
0644
edit
dl
rm
token.html
22660
0644
edit
dl
rm
tokenize.html
32149
0644
edit
dl
rm
trace.html
29145
0644
edit
dl
rm
traceback.html
57588
0644
edit
dl
rm
tracemalloc.html
101144
0644
edit
dl
rm
tty.html
10540
0644
edit
dl
rm
turtle.html
250367
0644
edit
dl
rm
types.html
37060
0644
edit
dl
rm
typing.html
139175
0644
edit
dl
rm
undoc.html
9181
0644
edit
dl
rm
unicodedata.html
21108
0644
edit
dl
rm
unittest.html
250689
0644
edit
dl
rm
unittest.mock-examples.html
168144
0644
edit
dl
rm
unittest.mock.html
300089
0644
edit
dl
rm
unix.html
11780
0644
edit
dl
rm
urllib.error.html
14474
0644
edit
dl
rm
urllib.html
9566
0644
edit
dl
rm
urllib.parse.html
76334
0644
edit
dl
rm
urllib.request.html
177199
0644
edit
dl
rm
urllib.robotparser.html
17156
0644
edit
dl
rm
uu.html
12209
0644
edit
dl
rm
uuid.html
31957
0644
edit
dl
rm
venv.html
73909
0644
edit
dl
rm
warnings.html
50320
0644
edit
dl
rm
wave.html
29868
0644
edit
dl
rm
weakref.html
65292
0644
edit
dl
rm
webbrowser.html
26901
0644
edit
dl
rm
windows.html
10626
0644
edit
dl
rm
winreg.html
66730
0644
edit
dl
rm
winsound.html
21268
0644
edit
dl
rm
wsgiref.html
94492
0644
edit
dl
rm
xdrlib.html
33751
0644
edit
dl
rm
xml.dom.html
97570
0644
edit
dl
rm
xml.dom.minidom.html
41481
0644
edit
dl
rm
xml.dom.pulldom.html
24214
0644
edit
dl
rm
xml.etree.elementtree.html
135491
0644
edit
dl
rm
xml.html
19261
0644
edit
dl
rm
xml.sax.handler.html
42659
0644
edit
dl
rm
xml.sax.html
25515
0644
edit
dl
rm
xml.sax.reader.html
45869
0644
edit
dl
rm
xml.sax.utils.html
16928
0644
edit
dl
rm
xmlrpc.client.html
71947
0644
edit
dl
rm
xmlrpc.html
8535
0644
edit
dl
rm
xmlrpc.server.html
49195
0644
edit
dl
rm
zipapp.html
45105
0644
edit
dl
rm
zipfile.html
80039
0644
edit
dl
rm
zipimport.html
23052
0644
edit
dl
rm
zlib.html
34557
0644
edit
dl
rm
_dummy_thread.html
9193
0644
edit
dl
rm
_thread.html
22588
0644
edit
dl
rm
__future__.html
15792
0644
edit
dl
rm
__main__.html
9019
0644
edit
dl
rm
Edit:
/usr/share/doc/python3-docs/html/library/time.html
(79629B)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>16.3. time — Time access and conversions — Python 3.6.7 documentation</title> <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 3.6.7 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="next" title="16.4. argparse — Parser for command-line options, arguments and sub-commands" href="argparse.html" /> <link rel="prev" title="16.2. io — Core tools for working with streams" href="io.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <link rel="canonical" href="https://docs.python.org/3/library/time.html" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="argparse.html" title="16.4. argparse — Parser for command-line options, arguments and sub-commands" accesskey="N">next</a> |</li> <li class="right" > <a href="io.html" title="16.2. io — Core tools for working with streams" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">3.6.7 Documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="allos.html" accesskey="U">16. Generic Operating System Services</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-time"> <span id="time-time-access-and-conversions"></span><h1>16.3. <a class="reference internal" href="#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> — Time access and conversions<a class="headerlink" href="#module-time" title="Permalink to this headline">¶</a></h1> <hr class="docutils" /> <p>This module provides various time-related functions. For related functionality, see also the <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a> and <a class="reference internal" href="calendar.html#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a> modules.</p> <p>Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.</p> <p>An explanation of some terminology and conventions is in order.</p> <span class="target" id="epoch"></span><ul class="simple" id="index-0"> <li>The <em class="dfn">epoch</em> is the point where the time starts, and is platform dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC). To find out what the epoch is on a given platform, look at <code class="docutils literal notranslate"><span class="pre">time.gmtime(0)</span></code>.</li> </ul> <ul class="simple" id="index-1"> <li>The term <em class="dfn">seconds since the epoch</em> refers to the total number of elapsed seconds since the epoch, typically excluding <a class="reference external" href="https://en.wikipedia.org/wiki/Leap_second">leap seconds</a>. Leap seconds are excluded from this total on all POSIX-compliant platforms.</li> </ul> <ul class="simple" id="index-2"> <li>The functions in this module may not handle dates and times before the epoch or far in the future. The cut-off point in the future is determined by the C library; for 32-bit systems, it is typically in 2038.</li> </ul> <span id="index-3"></span><ul class="simple" id="time-y2kissues"> <li><strong>Year 2000 (Y2K) issues</strong>: Python depends on the platform’s C library, which generally doesn’t have year 2000 issues, since all dates and times are represented internally as seconds since the epoch. Function <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a> can parse 2-digit years when given <code class="docutils literal notranslate"><span class="pre">%y</span></code> format code. When 2-digit years are parsed, they are converted according to the POSIX and ISO C standards: values 69–99 are mapped to 1969–1999, and values 0–68 are mapped to 2000–2068.</li> </ul> <ul class="simple" id="index-4"> <li>UTC is Coordinated Universal Time (formerly known as Greenwich Mean Time, or GMT). The acronym UTC is not a mistake but a compromise between English and French.</li> </ul> <ul id="index-5"> <li><p class="first">DST is Daylight Saving Time, an adjustment of the timezone by (usually) one hour during part of the year. DST rules are magic (determined by local law) and can change from year to year. The C library has a table containing the local rules (often it is read from a system file for flexibility) and is the only source of True Wisdom in this respect.</p> </li> <li><p class="first">The precision of the various real-time functions may be less than suggested by the units in which their value or argument is expressed. E.g. on most Unix systems, the clock “ticks” only 50 or 100 times a second.</p> </li> <li><p class="first">On the other hand, the precision of <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a> and <a class="reference internal" href="#time.sleep" title="time.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">sleep()</span></code></a> is better than their Unix equivalents: times are expressed as floating point numbers, <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a> returns the most accurate time available (using Unix <code class="xref c c-func docutils literal notranslate"><span class="pre">gettimeofday()</span></code> where available), and <a class="reference internal" href="#time.sleep" title="time.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">sleep()</span></code></a> will accept a time with a nonzero fraction (Unix <code class="xref c c-func docutils literal notranslate"><span class="pre">select()</span></code> is used to implement this, where available).</p> </li> <li><p class="first">The time value as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a>, <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a>, and <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a>, and accepted by <a class="reference internal" href="#time.asctime" title="time.asctime"><code class="xref py py-func docutils literal notranslate"><span class="pre">asctime()</span></code></a>, <a class="reference internal" href="#time.mktime" title="time.mktime"><code class="xref py py-func docutils literal notranslate"><span class="pre">mktime()</span></code></a> and <a class="reference internal" href="#time.strftime" title="time.strftime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strftime()</span></code></a>, is a sequence of 9 integers. The return values of <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a>, <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a>, and <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a> also offer attribute names for individual fields.</p> <p>See <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> for a description of these objects.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 3.3: </span>The <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> type was extended to provide the <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_gmtoff</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_zone</span></code> attributes when platform supports corresponding <code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">tm</span></code> members.</p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 3.6: </span>The <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> attributes <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_gmtoff</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_zone</span></code> are now available on all platforms.</p> </div> </li> <li><p class="first">Use the following functions to convert between time representations:</p> <table border="1" class="docutils"> <colgroup> <col width="33%" /> <col width="33%" /> <col width="33%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">From</th> <th class="head">To</th> <th class="head">Use</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>seconds since the epoch</td> <td><a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> in UTC</td> <td><a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a></td> </tr> <tr class="row-odd"><td>seconds since the epoch</td> <td><a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> in local time</td> <td><a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a></td> </tr> <tr class="row-even"><td><a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> in UTC</td> <td>seconds since the epoch</td> <td><a class="reference internal" href="calendar.html#calendar.timegm" title="calendar.timegm"><code class="xref py py-func docutils literal notranslate"><span class="pre">calendar.timegm()</span></code></a></td> </tr> <tr class="row-odd"><td><a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> in local time</td> <td>seconds since the epoch</td> <td><a class="reference internal" href="#time.mktime" title="time.mktime"><code class="xref py py-func docutils literal notranslate"><span class="pre">mktime()</span></code></a></td> </tr> </tbody> </table> </li> </ul> <div class="section" id="functions"> <span id="time-functions"></span><h2>16.3.1. Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="time.asctime"> <code class="descclassname">time.</code><code class="descname">asctime</code><span class="sig-paren">(</span><span class="optional">[</span><em>t</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#time.asctime" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a tuple or <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> representing a time as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> or <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> to a string of the following form: <code class="docutils literal notranslate"><span class="pre">'Sun</span> <span class="pre">Jun</span> <span class="pre">20</span> <span class="pre">23:21:05</span> <span class="pre">1993'</span></code>. If <em>t</em> is not provided, the current time as returned by <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> is used. Locale information is not used by <a class="reference internal" href="#time.asctime" title="time.asctime"><code class="xref py py-func docutils literal notranslate"><span class="pre">asctime()</span></code></a>.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Unlike the C function of the same name, <a class="reference internal" href="#time.asctime" title="time.asctime"><code class="xref py py-func docutils literal notranslate"><span class="pre">asctime()</span></code></a> does not add a trailing newline.</p> </div> </dd></dl> <dl class="function"> <dt id="time.clock"> <code class="descclassname">time.</code><code class="descname">clock</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#time.clock" title="Permalink to this definition">¶</a></dt> <dd><p id="index-6">On Unix, return the current processor time as a floating point number expressed in seconds. The precision, and in fact the very definition of the meaning of “processor time”, depends on that of the C function of the same name.</p> <p>On Windows, this function returns wall-clock seconds elapsed since the first call to this function, as a floating point number, based on the Win32 function <code class="xref c c-func docutils literal notranslate"><span class="pre">QueryPerformanceCounter()</span></code>. The resolution is typically better than one microsecond.</p> <div class="deprecated"> <p><span class="versionmodified">Deprecated since version 3.3: </span>The behaviour of this function depends on the platform: use <a class="reference internal" href="#time.perf_counter" title="time.perf_counter"><code class="xref py py-func docutils literal notranslate"><span class="pre">perf_counter()</span></code></a> or <a class="reference internal" href="#time.process_time" title="time.process_time"><code class="xref py py-func docutils literal notranslate"><span class="pre">process_time()</span></code></a> instead, depending on your requirements, to have a well defined behaviour.</p> </div> </dd></dl> <dl class="function"> <dt id="time.clock_getres"> <code class="descclassname">time.</code><code class="descname">clock_getres</code><span class="sig-paren">(</span><em>clk_id</em><span class="sig-paren">)</span><a class="headerlink" href="#time.clock_getres" title="Permalink to this definition">¶</a></dt> <dd><p>Return the resolution (precision) of the specified clock <em>clk_id</em>. Refer to <a class="reference internal" href="#time-clock-id-constants"><span class="std std-ref">Clock ID Constants</span></a> for a list of accepted values for <em>clk_id</em>.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="time.clock_gettime"> <code class="descclassname">time.</code><code class="descname">clock_gettime</code><span class="sig-paren">(</span><em>clk_id</em><span class="sig-paren">)</span><a class="headerlink" href="#time.clock_gettime" title="Permalink to this definition">¶</a></dt> <dd><p>Return the time of the specified clock <em>clk_id</em>. Refer to <a class="reference internal" href="#time-clock-id-constants"><span class="std std-ref">Clock ID Constants</span></a> for a list of accepted values for <em>clk_id</em>.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="time.clock_settime"> <code class="descclassname">time.</code><code class="descname">clock_settime</code><span class="sig-paren">(</span><em>clk_id</em>, <em>time</em><span class="sig-paren">)</span><a class="headerlink" href="#time.clock_settime" title="Permalink to this definition">¶</a></dt> <dd><p>Set the time of the specified clock <em>clk_id</em>. Currently, <a class="reference internal" href="#time.CLOCK_REALTIME" title="time.CLOCK_REALTIME"><code class="xref py py-data docutils literal notranslate"><span class="pre">CLOCK_REALTIME</span></code></a> is the only accepted value for <em>clk_id</em>.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="time.ctime"> <code class="descclassname">time.</code><code class="descname">ctime</code><span class="sig-paren">(</span><span class="optional">[</span><em>secs</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#time.ctime" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a time expressed in seconds since the epoch to a string representing local time. If <em>secs</em> is not provided or <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>, the current time as returned by <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a> is used. <code class="docutils literal notranslate"><span class="pre">ctime(secs)</span></code> is equivalent to <code class="docutils literal notranslate"><span class="pre">asctime(localtime(secs))</span></code>. Locale information is not used by <a class="reference internal" href="#time.ctime" title="time.ctime"><code class="xref py py-func docutils literal notranslate"><span class="pre">ctime()</span></code></a>.</p> </dd></dl> <dl class="function"> <dt id="time.get_clock_info"> <code class="descclassname">time.</code><code class="descname">get_clock_info</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#time.get_clock_info" title="Permalink to this definition">¶</a></dt> <dd><p>Get information on the specified clock as a namespace object. Supported clock names and the corresponding functions to read their value are:</p> <ul class="simple"> <li><code class="docutils literal notranslate"><span class="pre">'clock'</span></code>: <a class="reference internal" href="#time.clock" title="time.clock"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.clock()</span></code></a></li> <li><code class="docutils literal notranslate"><span class="pre">'monotonic'</span></code>: <a class="reference internal" href="#time.monotonic" title="time.monotonic"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.monotonic()</span></code></a></li> <li><code class="docutils literal notranslate"><span class="pre">'perf_counter'</span></code>: <a class="reference internal" href="#time.perf_counter" title="time.perf_counter"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.perf_counter()</span></code></a></li> <li><code class="docutils literal notranslate"><span class="pre">'process_time'</span></code>: <a class="reference internal" href="#time.process_time" title="time.process_time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.process_time()</span></code></a></li> <li><code class="docutils literal notranslate"><span class="pre">'time'</span></code>: <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time()</span></code></a></li> </ul> <p>The result has the following attributes:</p> <ul class="simple"> <li><em>adjustable</em>: <code class="docutils literal notranslate"><span class="pre">True</span></code> if the clock can be changed automatically (e.g. by a NTP daemon) or manually by the system administrator, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise</li> <li><em>implementation</em>: The name of the underlying C function used to get the clock value. Refer to <a class="reference internal" href="#time-clock-id-constants"><span class="std std-ref">Clock ID Constants</span></a> for possible values.</li> <li><em>monotonic</em>: <code class="docutils literal notranslate"><span class="pre">True</span></code> if the clock cannot go backward, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise</li> <li><em>resolution</em>: The resolution of the clock in seconds (<a class="reference internal" href="functions.html#float" title="float"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>)</li> </ul> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="time.gmtime"> <code class="descclassname">time.</code><code class="descname">gmtime</code><span class="sig-paren">(</span><span class="optional">[</span><em>secs</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#time.gmtime" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a time expressed in seconds since the epoch to a <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> in UTC in which the dst flag is always zero. If <em>secs</em> is not provided or <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>, the current time as returned by <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a> is used. Fractions of a second are ignored. See above for a description of the <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> object. See <a class="reference internal" href="calendar.html#calendar.timegm" title="calendar.timegm"><code class="xref py py-func docutils literal notranslate"><span class="pre">calendar.timegm()</span></code></a> for the inverse of this function.</p> </dd></dl> <dl class="function"> <dt id="time.localtime"> <code class="descclassname">time.</code><code class="descname">localtime</code><span class="sig-paren">(</span><span class="optional">[</span><em>secs</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#time.localtime" title="Permalink to this definition">¶</a></dt> <dd><p>Like <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> but converts to local time. If <em>secs</em> is not provided or <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a>, the current time as returned by <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a> is used. The dst flag is set to <code class="docutils literal notranslate"><span class="pre">1</span></code> when DST applies to the given time.</p> </dd></dl> <dl class="function"> <dt id="time.mktime"> <code class="descclassname">time.</code><code class="descname">mktime</code><span class="sig-paren">(</span><em>t</em><span class="sig-paren">)</span><a class="headerlink" href="#time.mktime" title="Permalink to this definition">¶</a></dt> <dd><p>This is the inverse function of <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a>. Its argument is the <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> or full 9-tuple (since the dst flag is needed; use <code class="docutils literal notranslate"><span class="pre">-1</span></code> as the dst flag if it is unknown) which expresses the time in <em>local</em> time, not UTC. It returns a floating point number, for compatibility with <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a>. If the input value cannot be represented as a valid time, either <a class="reference internal" href="exceptions.html#OverflowError" title="OverflowError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OverflowError</span></code></a> or <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> will be raised (which depends on whether the invalid value is caught by Python or the underlying C libraries). The earliest date for which it can generate a time is platform-dependent.</p> </dd></dl> <dl class="function"> <dt id="time.monotonic"> <code class="descclassname">time.</code><code class="descname">monotonic</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#time.monotonic" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value (in fractional seconds) of a monotonic clock, i.e. a clock that cannot go backwards. The clock is not affected by system clock updates. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid.</p> <p>On Windows versions older than Vista, <a class="reference internal" href="#time.monotonic" title="time.monotonic"><code class="xref py py-func docutils literal notranslate"><span class="pre">monotonic()</span></code></a> detects <code class="xref c c-func docutils literal notranslate"><span class="pre">GetTickCount()</span></code> integer overflow (32 bits, roll-over after 49.7 days). It increases an internal epoch (reference time) by 2<sup>32</sup> each time that an overflow is detected. The epoch is stored in the process-local state and so the value of <a class="reference internal" href="#time.monotonic" title="time.monotonic"><code class="xref py py-func docutils literal notranslate"><span class="pre">monotonic()</span></code></a> may be different in two Python processes running for more than 49 days. On more recent versions of Windows and on other operating systems, <a class="reference internal" href="#time.monotonic" title="time.monotonic"><code class="xref py py-func docutils literal notranslate"><span class="pre">monotonic()</span></code></a> is system-wide.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 3.5: </span>The function is now always available.</p> </div> </dd></dl> <dl class="function"> <dt id="time.perf_counter"> <code class="descclassname">time.</code><code class="descname">perf_counter</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#time.perf_counter" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value (in fractional seconds) of a performance counter, i.e. a clock with the highest available resolution to measure a short duration. It does include time elapsed during sleep and is system-wide. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="time.process_time"> <code class="descclassname">time.</code><code class="descname">process_time</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#time.process_time" title="Permalink to this definition">¶</a></dt> <dd><p>Return the value (in fractional seconds) of the sum of the system and user CPU time of the current process. It does not include time elapsed during sleep. It is process-wide by definition. The reference point of the returned value is undefined, so that only the difference between the results of consecutive calls is valid.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="function"> <dt id="time.sleep"> <code class="descclassname">time.</code><code class="descname">sleep</code><span class="sig-paren">(</span><em>secs</em><span class="sig-paren">)</span><a class="headerlink" href="#time.sleep" title="Permalink to this definition">¶</a></dt> <dd><p>Suspend execution of the calling thread for the given number of seconds. The argument may be a floating point number to indicate a more precise sleep time. The actual suspension time may be less than that requested because any caught signal will terminate the <a class="reference internal" href="#time.sleep" title="time.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">sleep()</span></code></a> following execution of that signal’s catching routine. Also, the suspension time may be longer than requested by an arbitrary amount because of the scheduling of other activity in the system.</p> <div class="versionchanged"> <p><span class="versionmodified">Changed in version 3.5: </span>The function now sleeps at least <em>secs</em> even if the sleep is interrupted by a signal, except if the signal handler raises an exception (see <span class="target" id="index-7"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0475"><strong>PEP 475</strong></a> for the rationale).</p> </div> </dd></dl> <dl class="function"> <dt id="time.strftime"> <code class="descclassname">time.</code><code class="descname">strftime</code><span class="sig-paren">(</span><em>format</em><span class="optional">[</span>, <em>t</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#time.strftime" title="Permalink to this definition">¶</a></dt> <dd><p>Convert a tuple or <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> representing a time as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> or <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> to a string as specified by the <em>format</em> argument. If <em>t</em> is not provided, the current time as returned by <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> is used. <em>format</em> must be a string. <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised if any field in <em>t</em> is outside of the allowed range.</p> <p>0 is a legal argument for any position in the time tuple; if it is normally illegal the value is forced to a correct one.</p> <p>The following directives can be embedded in the <em>format</em> string. They are shown without the optional field width and precision specification, and are replaced by the indicated characters in the <a class="reference internal" href="#time.strftime" title="time.strftime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strftime()</span></code></a> result:</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="73%" /> <col width="11%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Directive</th> <th class="head">Meaning</th> <th class="head">Notes</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%a</span></code></td> <td>Locale’s abbreviated weekday name.</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%A</span></code></td> <td>Locale’s full weekday name.</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%b</span></code></td> <td>Locale’s abbreviated month name.</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%B</span></code></td> <td>Locale’s full month name.</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%c</span></code></td> <td>Locale’s appropriate date and time representation.</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%d</span></code></td> <td>Day of the month as a decimal number [01,31].</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%H</span></code></td> <td>Hour (24-hour clock) as a decimal number [00,23].</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%I</span></code></td> <td>Hour (12-hour clock) as a decimal number [01,12].</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%j</span></code></td> <td>Day of the year as a decimal number [001,366].</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%m</span></code></td> <td>Month as a decimal number [01,12].</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%M</span></code></td> <td>Minute as a decimal number [00,59].</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%p</span></code></td> <td>Locale’s equivalent of either AM or PM.</td> <td>(1)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%S</span></code></td> <td>Second as a decimal number [00,61].</td> <td>(2)</td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%U</span></code></td> <td>Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.</td> <td>(3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%w</span></code></td> <td>Weekday as a decimal number [0(Sunday),6].</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%W</span></code></td> <td>Week number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.</td> <td>(3)</td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%x</span></code></td> <td>Locale’s appropriate date representation.</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%X</span></code></td> <td>Locale’s appropriate time representation.</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%y</span></code></td> <td>Year without century as a decimal number [00,99].</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%Y</span></code></td> <td>Year with century as a decimal number.</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%z</span></code></td> <td>Time zone offset indicating a positive or negative time difference from UTC/GMT of the form +HHMM or -HHMM, where H represents decimal hour digits and M represents decimal minute digits [-23:59, +23:59].</td> <td> </td> </tr> <tr class="row-odd"><td><code class="docutils literal notranslate"><span class="pre">%Z</span></code></td> <td>Time zone name (no characters if no time zone exists).</td> <td> </td> </tr> <tr class="row-even"><td><code class="docutils literal notranslate"><span class="pre">%%</span></code></td> <td>A literal <code class="docutils literal notranslate"><span class="pre">'%'</span></code> character.</td> <td> </td> </tr> </tbody> </table> <p>Notes:</p> <ol class="arabic simple"> <li>When used with the <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a> function, the <code class="docutils literal notranslate"><span class="pre">%p</span></code> directive only affects the output hour field if the <code class="docutils literal notranslate"><span class="pre">%I</span></code> directive is used to parse the hour.</li> <li>The range really is <code class="docutils literal notranslate"><span class="pre">0</span></code> to <code class="docutils literal notranslate"><span class="pre">61</span></code>; value <code class="docutils literal notranslate"><span class="pre">60</span></code> is valid in timestamps representing <a class="reference external" href="https://en.wikipedia.org/wiki/Leap_second">leap seconds</a> and value <code class="docutils literal notranslate"><span class="pre">61</span></code> is supported for historical reasons.</li> <li>When used with the <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a> function, <code class="docutils literal notranslate"><span class="pre">%U</span></code> and <code class="docutils literal notranslate"><span class="pre">%W</span></code> are only used in calculations when the day of the week and the year are specified.</li> </ol> <p>Here is an example, a format for dates compatible with that specified in the <span class="target" id="index-8"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a> Internet email standard. <a class="footnote-reference" href="#id2" id="id1">[1]</a></p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">time</span> <span class="k">import</span> <span class="n">gmtime</span><span class="p">,</span> <span class="n">strftime</span> <span class="gp">>>> </span><span class="n">strftime</span><span class="p">(</span><span class="s2">"%a, </span><span class="si">%d</span><span class="s2"> %b %Y %H:%M:%S +0000"</span><span class="p">,</span> <span class="n">gmtime</span><span class="p">())</span> <span class="go">'Thu, 28 Jun 2001 14:17:15 +0000'</span> </pre></div> </div> <p>Additional directives may be supported on certain platforms, but only the ones listed here have a meaning standardized by ANSI C. To see the full set of format codes supported on your platform, consult the <em class="manpage">strftime(3)</em> documentation.</p> <p>On some platforms, an optional field width and precision specification can immediately follow the initial <code class="docutils literal notranslate"><span class="pre">'%'</span></code> of a directive in the following order; this is also not portable. The field width is normally 2 except for <code class="docutils literal notranslate"><span class="pre">%j</span></code> where it is 3.</p> </dd></dl> <dl class="function"> <dt id="time.strptime"> <code class="descclassname">time.</code><code class="descname">strptime</code><span class="sig-paren">(</span><em>string</em><span class="optional">[</span>, <em>format</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#time.strptime" title="Permalink to this definition">¶</a></dt> <dd><p>Parse a string representing a time according to a format. The return value is a <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> or <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a>.</p> <p>The <em>format</em> parameter uses the same directives as those used by <a class="reference internal" href="#time.strftime" title="time.strftime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strftime()</span></code></a>; it defaults to <code class="docutils literal notranslate"><span class="pre">"%a</span> <span class="pre">%b</span> <span class="pre">%d</span> <span class="pre">%H:%M:%S</span> <span class="pre">%Y"</span></code> which matches the formatting returned by <a class="reference internal" href="#time.ctime" title="time.ctime"><code class="xref py py-func docutils literal notranslate"><span class="pre">ctime()</span></code></a>. If <em>string</em> cannot be parsed according to <em>format</em>, or if it has excess data after parsing, <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised. The default values used to fill in any missing data when more accurate values cannot be inferred are <code class="docutils literal notranslate"><span class="pre">(1900,</span> <span class="pre">1,</span> <span class="pre">1,</span> <span class="pre">0,</span> <span class="pre">0,</span> <span class="pre">0,</span> <span class="pre">0,</span> <span class="pre">1,</span> <span class="pre">-1)</span></code>. Both <em>string</em> and <em>format</em> must be strings.</p> <p>For example:</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">time</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="s2">"30 Nov 00"</span><span class="p">,</span> <span class="s2">"</span><span class="si">%d</span><span class="s2"> %b %y"</span><span class="p">)</span> <span class="go">time.struct_time(tm_year=2000, tm_mon=11, tm_mday=30, tm_hour=0, tm_min=0,</span> <span class="go"> tm_sec=0, tm_wday=3, tm_yday=335, tm_isdst=-1)</span> </pre></div> </div> <p>Support for the <code class="docutils literal notranslate"><span class="pre">%Z</span></code> directive is based on the values contained in <code class="docutils literal notranslate"><span class="pre">tzname</span></code> and whether <code class="docutils literal notranslate"><span class="pre">daylight</span></code> is true. Because of this, it is platform-specific except for recognizing UTC and GMT which are always known (and are considered to be non-daylight savings timezones).</p> <p>Only the directives specified in the documentation are supported. Because <code class="docutils literal notranslate"><span class="pre">strftime()</span></code> is implemented per platform it can sometimes offer more directives than those listed. But <code class="docutils literal notranslate"><span class="pre">strptime()</span></code> is independent of any platform and thus does not necessarily support all directives available that are not documented as supported.</p> </dd></dl> <dl class="class"> <dt id="time.struct_time"> <em class="property">class </em><code class="descclassname">time.</code><code class="descname">struct_time</code><a class="headerlink" href="#time.struct_time" title="Permalink to this definition">¶</a></dt> <dd><p>The type of the time value sequence returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a>, <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a>, and <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a>. It is an object with a <a class="reference internal" href="../glossary.html#term-named-tuple"><span class="xref std std-term">named tuple</span></a> interface: values can be accessed by index and by attribute name. The following values are present:</p> <table border="1" class="docutils"> <colgroup> <col width="12%" /> <col width="32%" /> <col width="56%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Index</th> <th class="head">Attribute</th> <th class="head">Values</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>0</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_year</span></code></td> <td>(for example, 1993)</td> </tr> <tr class="row-odd"><td>1</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_mon</span></code></td> <td>range [1, 12]</td> </tr> <tr class="row-even"><td>2</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_mday</span></code></td> <td>range [1, 31]</td> </tr> <tr class="row-odd"><td>3</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_hour</span></code></td> <td>range [0, 23]</td> </tr> <tr class="row-even"><td>4</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_min</span></code></td> <td>range [0, 59]</td> </tr> <tr class="row-odd"><td>5</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_sec</span></code></td> <td>range [0, 61]; see <strong>(2)</strong> in <a class="reference internal" href="#time.strftime" title="time.strftime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strftime()</span></code></a> description</td> </tr> <tr class="row-even"><td>6</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_wday</span></code></td> <td>range [0, 6], Monday is 0</td> </tr> <tr class="row-odd"><td>7</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_yday</span></code></td> <td>range [1, 366]</td> </tr> <tr class="row-even"><td>8</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_isdst</span></code></td> <td>0, 1 or -1; see below</td> </tr> <tr class="row-odd"><td>N/A</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_zone</span></code></td> <td>abbreviation of timezone name</td> </tr> <tr class="row-even"><td>N/A</td> <td><code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_gmtoff</span></code></td> <td>offset east of UTC in seconds</td> </tr> </tbody> </table> <p>Note that unlike the C structure, the month value is a range of [1, 12], not [0, 11].</p> <p>In calls to <a class="reference internal" href="#time.mktime" title="time.mktime"><code class="xref py py-func docutils literal notranslate"><span class="pre">mktime()</span></code></a>, <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_isdst</span></code> may be set to 1 when daylight savings time is in effect, and 0 when it is not. A value of -1 indicates that this is not known, and will usually result in the correct state being filled in.</p> <p>When a tuple with an incorrect length is passed to a function expecting a <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a>, or having elements of the wrong type, a <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> is raised.</p> </dd></dl> <dl class="function"> <dt id="time.time"> <code class="descclassname">time.</code><code class="descname">time</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#time.time" title="Permalink to this definition">¶</a></dt> <dd><p>Return the time in seconds since the <a class="reference internal" href="#epoch">epoch</a> as a floating point number. The specific date of the epoch and the handling of <a class="reference external" href="https://en.wikipedia.org/wiki/Leap_second">leap seconds</a> is platform dependent. On Windows and most Unix systems, the epoch is January 1, 1970, 00:00:00 (UTC) and leap seconds are not counted towards the time in seconds since the epoch. This is commonly referred to as <a class="reference external" href="https://en.wikipedia.org/wiki/Unix_time">Unix time</a>. To find out what the epoch is on a given platform, look at <code class="docutils literal notranslate"><span class="pre">gmtime(0)</span></code>.</p> <p>Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls.</p> <p>The number returned by <a class="reference internal" href="#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time()</span></code></a> may be converted into a more common time format (i.e. year, month, day, hour, etc…) in UTC by passing it to <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> function or in local time by passing it to the <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> function. In both cases a <a class="reference internal" href="#time.struct_time" title="time.struct_time"><code class="xref py py-class docutils literal notranslate"><span class="pre">struct_time</span></code></a> object is returned, from which the components of the calendar date may be accessed as attributes.</p> </dd></dl> <dl class="function"> <dt id="time.tzset"> <code class="descclassname">time.</code><code class="descname">tzset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#time.tzset" title="Permalink to this definition">¶</a></dt> <dd><p>Resets the time conversion rules used by the library routines. The environment variable <span class="target" id="index-9"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TZ</span></code> specifies how this is done.</p> <p>Availability: Unix.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p>Although in many cases, changing the <span class="target" id="index-10"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TZ</span></code> environment variable may affect the output of functions like <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> without calling <a class="reference internal" href="#time.tzset" title="time.tzset"><code class="xref py py-func docutils literal notranslate"><span class="pre">tzset()</span></code></a>, this behavior should not be relied on.</p> <p class="last">The <span class="target" id="index-11"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TZ</span></code> environment variable should contain no whitespace.</p> </div> <p>The standard format of the <span class="target" id="index-12"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TZ</span></code> environment variable is (whitespace added for clarity):</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">std</span> <span class="n">offset</span> <span class="p">[</span><span class="n">dst</span> <span class="p">[</span><span class="n">offset</span> <span class="p">[,</span><span class="n">start</span><span class="p">[</span><span class="o">/</span><span class="n">time</span><span class="p">],</span> <span class="n">end</span><span class="p">[</span><span class="o">/</span><span class="n">time</span><span class="p">]]]]</span> </pre></div> </div> <p>Where the components are:</p> <dl class="docutils"> <dt><code class="docutils literal notranslate"><span class="pre">std</span></code> and <code class="docutils literal notranslate"><span class="pre">dst</span></code></dt> <dd>Three or more alphanumerics giving the timezone abbreviations. These will be propagated into time.tzname</dd> <dt><code class="docutils literal notranslate"><span class="pre">offset</span></code></dt> <dd>The offset has the form: <code class="docutils literal notranslate"><span class="pre">±</span> <span class="pre">hh[:mm[:ss]]</span></code>. This indicates the value added the local time to arrive at UTC. If preceded by a ‘-‘, the timezone is east of the Prime Meridian; otherwise, it is west. If no offset follows dst, summer time is assumed to be one hour ahead of standard time.</dd> <dt><code class="docutils literal notranslate"><span class="pre">start[/time],</span> <span class="pre">end[/time]</span></code></dt> <dd><p class="first">Indicates when to change to and back from DST. The format of the start and end dates are one of the following:</p> <dl class="docutils"> <dt><code class="samp docutils literal notranslate"><span class="pre">J</span><em><span class="pre">n</span></em></code></dt> <dd>The Julian day <em>n</em> (1 <= <em>n</em> <= 365). Leap days are not counted, so in all years February 28 is day 59 and March 1 is day 60.</dd> <dt><code class="samp docutils literal notranslate"><em><span class="pre">n</span></em></code></dt> <dd>The zero-based Julian day (0 <= <em>n</em> <= 365). Leap days are counted, and it is possible to refer to February 29.</dd> <dt><code class="samp docutils literal notranslate"><span class="pre">M</span><em><span class="pre">m</span></em><span class="pre">.</span><em><span class="pre">n</span></em><span class="pre">.</span><em><span class="pre">d</span></em></code></dt> <dd>The <em>d</em>’th day (0 <= <em>d</em> <= 6) of week <em>n</em> of month <em>m</em> of the year (1 <= <em>n</em> <= 5, 1 <= <em>m</em> <= 12, where week 5 means “the last <em>d</em> day in month <em>m</em>” which may occur in either the fourth or the fifth week). Week 1 is the first week in which the <em>d</em>’th day occurs. Day zero is a Sunday.</dd> </dl> <p class="last"><code class="docutils literal notranslate"><span class="pre">time</span></code> has the same format as <code class="docutils literal notranslate"><span class="pre">offset</span></code> except that no leading sign (‘-‘ or ‘+’) is allowed. The default, if time is not given, is 02:00:00.</p> </dd> </dl> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'EST+05EDT,M4.1.0,M10.5.0'</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">tzset</span><span class="p">()</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">'</span><span class="si">%X</span><span class="s1"> </span><span class="si">%x</span><span class="s1"> %Z'</span><span class="p">)</span> <span class="go">'02:07:36 05/08/03 EDT'</span> <span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'AEST-10AEDT-11,M10.5.0,M3.5.0'</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">tzset</span><span class="p">()</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="s1">'</span><span class="si">%X</span><span class="s1"> </span><span class="si">%x</span><span class="s1"> %Z'</span><span class="p">)</span> <span class="go">'16:08:12 05/08/03 AEST'</span> </pre></div> </div> <p>On many Unix systems (including *BSD, Linux, Solaris, and Darwin), it is more convenient to use the system’s zoneinfo (<em class="manpage">tzfile(5)</em>) database to specify the timezone rules. To do this, set the <span class="target" id="index-13"></span><code class="xref std std-envvar docutils literal notranslate"><span class="pre">TZ</span></code> environment variable to the path of the required timezone datafile, relative to the root of the systems ‘zoneinfo’ timezone database, usually located at <code class="file docutils literal notranslate"><span class="pre">/usr/share/zoneinfo</span></code>. For example, <code class="docutils literal notranslate"><span class="pre">'US/Eastern'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Australia/Melbourne'</span></code>, <code class="docutils literal notranslate"><span class="pre">'Egypt'</span></code> or <code class="docutils literal notranslate"><span class="pre">'Europe/Amsterdam'</span></code>.</p> <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'US/Eastern'</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">tzset</span><span class="p">()</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">tzname</span> <span class="go">('EST', 'EDT')</span> <span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s1">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'Egypt'</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">tzset</span><span class="p">()</span> <span class="gp">>>> </span><span class="n">time</span><span class="o">.</span><span class="n">tzname</span> <span class="go">('EET', 'EEST')</span> </pre></div> </div> </dd></dl> </div> <div class="section" id="clock-id-constants"> <span id="time-clock-id-constants"></span><h2>16.3.2. Clock ID Constants<a class="headerlink" href="#clock-id-constants" title="Permalink to this headline">¶</a></h2> <p>These constants are used as parameters for <a class="reference internal" href="#time.clock_getres" title="time.clock_getres"><code class="xref py py-func docutils literal notranslate"><span class="pre">clock_getres()</span></code></a> and <a class="reference internal" href="#time.clock_gettime" title="time.clock_gettime"><code class="xref py py-func docutils literal notranslate"><span class="pre">clock_gettime()</span></code></a>.</p> <dl class="data"> <dt id="time.CLOCK_HIGHRES"> <code class="descclassname">time.</code><code class="descname">CLOCK_HIGHRES</code><a class="headerlink" href="#time.CLOCK_HIGHRES" title="Permalink to this definition">¶</a></dt> <dd><p>The Solaris OS has a <code class="docutils literal notranslate"><span class="pre">CLOCK_HIGHRES</span></code> timer that attempts to use an optimal hardware source, and may give close to nanosecond resolution. <code class="docutils literal notranslate"><span class="pre">CLOCK_HIGHRES</span></code> is the nonadjustable, high-resolution clock.</p> <p>Availability: Solaris.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="data"> <dt id="time.CLOCK_MONOTONIC"> <code class="descclassname">time.</code><code class="descname">CLOCK_MONOTONIC</code><a class="headerlink" href="#time.CLOCK_MONOTONIC" title="Permalink to this definition">¶</a></dt> <dd><p>Clock that cannot be set and represents monotonic time since some unspecified starting point.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="data"> <dt id="time.CLOCK_MONOTONIC_RAW"> <code class="descclassname">time.</code><code class="descname">CLOCK_MONOTONIC_RAW</code><a class="headerlink" href="#time.CLOCK_MONOTONIC_RAW" title="Permalink to this definition">¶</a></dt> <dd><p>Similar to <a class="reference internal" href="#time.CLOCK_MONOTONIC" title="time.CLOCK_MONOTONIC"><code class="xref py py-data docutils literal notranslate"><span class="pre">CLOCK_MONOTONIC</span></code></a>, but provides access to a raw hardware-based time that is not subject to NTP adjustments.</p> <p>Availability: Linux 2.6.28 or later.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="data"> <dt id="time.CLOCK_PROCESS_CPUTIME_ID"> <code class="descclassname">time.</code><code class="descname">CLOCK_PROCESS_CPUTIME_ID</code><a class="headerlink" href="#time.CLOCK_PROCESS_CPUTIME_ID" title="Permalink to this definition">¶</a></dt> <dd><p>High-resolution per-process timer from the CPU.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <dl class="data"> <dt id="time.CLOCK_THREAD_CPUTIME_ID"> <code class="descclassname">time.</code><code class="descname">CLOCK_THREAD_CPUTIME_ID</code><a class="headerlink" href="#time.CLOCK_THREAD_CPUTIME_ID" title="Permalink to this definition">¶</a></dt> <dd><p>Thread-specific CPU-time clock.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> <p>The following constant is the only parameter that can be sent to <a class="reference internal" href="#time.clock_settime" title="time.clock_settime"><code class="xref py py-func docutils literal notranslate"><span class="pre">clock_settime()</span></code></a>.</p> <dl class="data"> <dt id="time.CLOCK_REALTIME"> <code class="descclassname">time.</code><code class="descname">CLOCK_REALTIME</code><a class="headerlink" href="#time.CLOCK_REALTIME" title="Permalink to this definition">¶</a></dt> <dd><p>System-wide real-time clock. Setting this clock requires appropriate privileges.</p> <p>Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 3.3.</span></p> </div> </dd></dl> </div> <div class="section" id="timezone-constants"> <span id="time-timezone-constants"></span><h2>16.3.3. Timezone Constants<a class="headerlink" href="#timezone-constants" title="Permalink to this headline">¶</a></h2> <dl class="data"> <dt id="time.altzone"> <code class="descclassname">time.</code><code class="descname">altzone</code><a class="headerlink" href="#time.altzone" title="Permalink to this definition">¶</a></dt> <dd><p>The offset of the local DST timezone, in seconds west of UTC, if one is defined. This is negative if the local DST timezone is east of UTC (as in Western Europe, including the UK). Only use this if <code class="docutils literal notranslate"><span class="pre">daylight</span></code> is nonzero. See note below.</p> </dd></dl> <dl class="data"> <dt id="time.daylight"> <code class="descclassname">time.</code><code class="descname">daylight</code><a class="headerlink" href="#time.daylight" title="Permalink to this definition">¶</a></dt> <dd><p>Nonzero if a DST timezone is defined. See note below.</p> </dd></dl> <dl class="data"> <dt id="time.timezone"> <code class="descclassname">time.</code><code class="descname">timezone</code><a class="headerlink" href="#time.timezone" title="Permalink to this definition">¶</a></dt> <dd><p>The offset of the local (non-DST) timezone, in seconds west of UTC (negative in most of Western Europe, positive in the US, zero in the UK). See note below.</p> </dd></dl> <dl class="data"> <dt id="time.tzname"> <code class="descclassname">time.</code><code class="descname">tzname</code><a class="headerlink" href="#time.tzname" title="Permalink to this definition">¶</a></dt> <dd><p>A tuple of two strings: the first is the name of the local non-DST timezone, the second is the name of the local DST timezone. If no DST timezone is defined, the second string should not be used. See note below.</p> </dd></dl> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">For the above Timezone constants (<a class="reference internal" href="#time.altzone" title="time.altzone"><code class="xref py py-data docutils literal notranslate"><span class="pre">altzone</span></code></a>, <a class="reference internal" href="#time.daylight" title="time.daylight"><code class="xref py py-data docutils literal notranslate"><span class="pre">daylight</span></code></a>, <a class="reference internal" href="#time.timezone" title="time.timezone"><code class="xref py py-data docutils literal notranslate"><span class="pre">timezone</span></code></a>, and <a class="reference internal" href="#time.tzname" title="time.tzname"><code class="xref py py-data docutils literal notranslate"><span class="pre">tzname</span></code></a>), the value is determined by the timezone rules in effect at module load time or the last time <a class="reference internal" href="#time.tzset" title="time.tzset"><code class="xref py py-func docutils literal notranslate"><span class="pre">tzset()</span></code></a> is called and may be incorrect for times in the past. It is recommended to use the <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_gmtoff</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">tm_zone</span></code> results from <a class="reference internal" href="#time.localtime" title="time.localtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">localtime()</span></code></a> to obtain timezone information.</p> </div> <div class="admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt>Module <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a></dt> <dd>More object-oriented interface to dates and times.</dd> <dt>Module <a class="reference internal" href="locale.html#module-locale" title="locale: Internationalization services."><code class="xref py py-mod docutils literal notranslate"><span class="pre">locale</span></code></a></dt> <dd>Internationalization services. The locale setting affects the interpretation of many format specifiers in <a class="reference internal" href="#time.strftime" title="time.strftime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strftime()</span></code></a> and <a class="reference internal" href="#time.strptime" title="time.strptime"><code class="xref py py-func docutils literal notranslate"><span class="pre">strptime()</span></code></a>.</dd> <dt>Module <a class="reference internal" href="calendar.html#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a></dt> <dd>General calendar-related functions. <a class="reference internal" href="calendar.html#calendar.timegm" title="calendar.timegm"><code class="xref py py-func docutils literal notranslate"><span class="pre">timegm()</span></code></a> is the inverse of <a class="reference internal" href="#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> from this module.</dd> </dl> </div> <p class="rubric">Footnotes</p> <table class="docutils footnote" frame="void" id="id2" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>The use of <code class="docutils literal notranslate"><span class="pre">%Z</span></code> is now deprecated, but the <code class="docutils literal notranslate"><span class="pre">%z</span></code> escape that expands to the preferred hour/minute offset is not supported by all ANSI C libraries. Also, a strict reading of the original 1982 <span class="target" id="index-14"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc822.html"><strong>RFC 822</strong></a> standard calls for a two-digit year (%y rather than %Y), but practice moved to 4-digit years long before the year 2000. After that, <span class="target" id="index-15"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc822.html"><strong>RFC 822</strong></a> became obsolete and the 4-digit year has been first recommended by <span class="target" id="index-16"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc1123.html"><strong>RFC 1123</strong></a> and then mandated by <span class="target" id="index-17"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>.</td></tr> </tbody> </table> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">16.3. <code class="docutils literal notranslate"><span class="pre">time</span></code> — Time access and conversions</a><ul> <li><a class="reference internal" href="#functions">16.3.1. Functions</a></li> <li><a class="reference internal" href="#clock-id-constants">16.3.2. Clock ID Constants</a></li> <li><a class="reference internal" href="#timezone-constants">16.3.3. Timezone Constants</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="io.html" title="previous chapter">16.2. <code class="docutils literal notranslate"><span class="pre">io</span></code> — Core tools for working with streams</a></p> <h4>Next topic</h4> <p class="topless"><a href="argparse.html" title="next chapter">16.4. <code class="docutils literal notranslate"><span class="pre">argparse</span></code> — Parser for command-line options, arguments and sub-commands</a></p> <div role="note" aria-label="source link"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li> <a href="https://github.com/python/cpython/blob/3.6/Doc/library/time.rst" rel="nofollow">Show Source </a> </li> </ul> </div> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="argparse.html" title="16.4. argparse — Parser for command-line options, arguments and sub-commands" >next</a> |</li> <li class="right" > <a href="io.html" title="16.2. io — Core tools for working with streams" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> »</li> <li> <a href="../index.html">3.6.7 Documentation</a> » </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li> <li class="nav-item nav-item-2"><a href="allos.html" >16. Generic Operating System Services</a> »</li> <li class="right"> <div class="inline-search" style="display: none" role="search"> <form class="inline-search" action="../search.html" method="get"> <input placeholder="Quick search" type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> <script type="text/javascript">$('.inline-search').show(0);</script> | </li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 2001-2023, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Dec 18, 2023. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.7.6. </div> </body> </html>
Save
cmd:
run