Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els11.x86_64 #1 SMP Sun Nov 3 09:06:59 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.144.101.75
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python-docs-2.7.5 /
html /
library /
[ HOME SHELL ]
Name
Size
Permission
Action
2to3.html
49.27
KB
-rw-r--r--
__builtin__.html
10.26
KB
-rw-r--r--
__future__.html
13.79
KB
-rw-r--r--
__main__.html
7.05
KB
-rw-r--r--
_winreg.html
59.21
KB
-rw-r--r--
abc.html
23.9
KB
-rw-r--r--
aepack.html
13.16
KB
-rw-r--r--
aetools.html
14.91
KB
-rw-r--r--
aetypes.html
18.88
KB
-rw-r--r--
aifc.html
22.4
KB
-rw-r--r--
al.html
17.34
KB
-rw-r--r--
allos.html
33.72
KB
-rw-r--r--
anydbm.html
16.33
KB
-rw-r--r--
archiving.html
9.26
KB
-rw-r--r--
argparse.html
237.62
KB
-rw-r--r--
array.html
29.29
KB
-rw-r--r--
ast.html
34.98
KB
-rw-r--r--
asynchat.html
31.43
KB
-rw-r--r--
asyncore.html
36.51
KB
-rw-r--r--
atexit.html
16.8
KB
-rw-r--r--
audioop.html
31.36
KB
-rw-r--r--
autogil.html
8.19
KB
-rw-r--r--
base64.html
19.67
KB
-rw-r--r--
basehttpserver.html
34.04
KB
-rw-r--r--
bastion.html
11.04
KB
-rw-r--r--
bdb.html
36.68
KB
-rw-r--r--
binascii.html
20.67
KB
-rw-r--r--
binhex.html
10.58
KB
-rw-r--r--
bisect.html
23.24
KB
-rw-r--r--
bsddb.html
26.43
KB
-rw-r--r--
bz2.html
26.08
KB
-rw-r--r--
calendar.html
37.79
KB
-rw-r--r--
carbon.html
48.94
KB
-rw-r--r--
cd.html
27.96
KB
-rw-r--r--
cgi.html
49.92
KB
-rw-r--r--
cgihttpserver.html
13.1
KB
-rw-r--r--
cgitb.html
11.41
KB
-rw-r--r--
chunk.html
14.66
KB
-rw-r--r--
cmath.html
25.63
KB
-rw-r--r--
cmd.html
26.09
KB
-rw-r--r--
code.html
24.58
KB
-rw-r--r--
codecs.html
100.64
KB
-rw-r--r--
codeop.html
14.84
KB
-rw-r--r--
collections.html
133.96
KB
-rw-r--r--
colorpicker.html
7.52
KB
-rw-r--r--
colorsys.html
11.04
KB
-rw-r--r--
commands.html
14.36
KB
-rw-r--r--
compileall.html
16.83
KB
-rw-r--r--
compiler.html
67.75
KB
-rw-r--r--
configparser.html
62.13
KB
-rw-r--r--
constants.html
12.83
KB
-rw-r--r--
contextlib.html
19.39
KB
-rw-r--r--
cookie.html
39.07
KB
-rw-r--r--
cookielib.html
83.82
KB
-rw-r--r--
copy.html
12.19
KB
-rw-r--r--
copy_reg.html
13.76
KB
-rw-r--r--
crypt.html
10.04
KB
-rw-r--r--
crypto.html
7.59
KB
-rw-r--r--
csv.html
67.37
KB
-rw-r--r--
ctypes.html
238.78
KB
-rw-r--r--
curses.ascii.html
22.29
KB
-rw-r--r--
curses.html
146.63
KB
-rw-r--r--
curses.panel.html
14.39
KB
-rw-r--r--
custominterp.html
7.62
KB
-rw-r--r--
datatypes.html
16.84
KB
-rw-r--r--
datetime.html
226.59
KB
-rw-r--r--
dbhash.html
15.48
KB
-rw-r--r--
dbm.html
12.07
KB
-rw-r--r--
debug.html
10.15
KB
-rw-r--r--
decimal.html
194.44
KB
-rw-r--r--
development.html
14.17
KB
-rw-r--r--
difflib.html
84.83
KB
-rw-r--r--
dircache.html
11.41
KB
-rw-r--r--
dis.html
69.95
KB
-rw-r--r--
distutils.html
8.05
KB
-rw-r--r--
dl.html
16.33
KB
-rw-r--r--
doctest.html
165.54
KB
-rw-r--r--
docxmlrpcserver.html
16.43
KB
-rw-r--r--
dumbdbm.html
14.02
KB
-rw-r--r--
dummy_thread.html
9.43
KB
-rw-r--r--
dummy_threading.html
8.37
KB
-rw-r--r--
easydialogs.html
30.55
KB
-rw-r--r--
email-examples.html
45.65
KB
-rw-r--r--
email.charset.html
26.8
KB
-rw-r--r--
email.encoders.html
11.86
KB
-rw-r--r--
email.errors.html
15.77
KB
-rw-r--r--
email.generator.html
20.77
KB
-rw-r--r--
email.header.html
26.92
KB
-rw-r--r--
email.html
44.24
KB
-rw-r--r--
email.iterators.html
11.52
KB
-rw-r--r--
email.message.html
63.16
KB
-rw-r--r--
email.mime.html
27.93
KB
-rw-r--r--
email.parser.html
30.45
KB
-rw-r--r--
email.util.html
24.46
KB
-rw-r--r--
errno.html
37.99
KB
-rw-r--r--
exceptions.html
56.13
KB
-rw-r--r--
fcntl.html
22.67
KB
-rw-r--r--
filecmp.html
22.3
KB
-rw-r--r--
fileformats.html
9.14
KB
-rw-r--r--
fileinput.html
24.28
KB
-rw-r--r--
filesys.html
10.2
KB
-rw-r--r--
fl.html
49.92
KB
-rw-r--r--
fm.html
11.91
KB
-rw-r--r--
fnmatch.html
14.58
KB
-rw-r--r--
formatter.html
34.06
KB
-rw-r--r--
fpectl.html
16.01
KB
-rw-r--r--
fpformat.html
10.59
KB
-rw-r--r--
fractions.html
22.61
KB
-rw-r--r--
framework.html
33.34
KB
-rw-r--r--
frameworks.html
7.14
KB
-rw-r--r--
ftplib.html
43.99
KB
-rw-r--r--
functions.html
183.14
KB
-rw-r--r--
functools.html
27.17
KB
-rw-r--r--
future_builtins.html
13.04
KB
-rw-r--r--
gc.html
25.75
KB
-rw-r--r--
gdbm.html
15.96
KB
-rw-r--r--
gensuitemodule.html
11.51
KB
-rw-r--r--
getopt.html
23.66
KB
-rw-r--r--
getpass.html
10.65
KB
-rw-r--r--
gettext.html
78.76
KB
-rw-r--r--
gl.html
22.09
KB
-rw-r--r--
glob.html
13.26
KB
-rw-r--r--
grp.html
10.49
KB
-rw-r--r--
gzip.html
18.99
KB
-rw-r--r--
hashlib.html
18.2
KB
-rw-r--r--
heapq.html
31.61
KB
-rw-r--r--
hmac.html
10.46
KB
-rw-r--r--
hotshot.html
18.65
KB
-rw-r--r--
htmllib.html
25.32
KB
-rw-r--r--
htmlparser.html
39.11
KB
-rw-r--r--
httplib.html
62.95
KB
-rw-r--r--
i18n.html
9.52
KB
-rw-r--r--
ic.html
17.17
KB
-rw-r--r--
idle.html
20.9
KB
-rw-r--r--
imageop.html
14.76
KB
-rw-r--r--
imaplib.html
51.99
KB
-rw-r--r--
imgfile.html
11.71
KB
-rw-r--r--
imghdr.html
11.3
KB
-rw-r--r--
imp.html
34.34
KB
-rw-r--r--
importlib.html
8.26
KB
-rw-r--r--
imputil.html
31.81
KB
-rw-r--r--
index.html
72.78
KB
-rw-r--r--
inspect.html
50.71
KB
-rw-r--r--
internet.html
24.87
KB
-rw-r--r--
intro.html
8.93
KB
-rw-r--r--
io.html
98.13
KB
-rw-r--r--
ipc.html
13.41
KB
-rw-r--r--
itertools.html
115.91
KB
-rw-r--r--
jpeg.html
12.74
KB
-rw-r--r--
json.html
67.04
KB
-rw-r--r--
keyword.html
7.68
KB
-rw-r--r--
language.html
11.03
KB
-rw-r--r--
linecache.html
10.59
KB
-rw-r--r--
locale.html
55.14
KB
-rw-r--r--
logging.config.html
63.36
KB
-rw-r--r--
logging.handlers.html
69.64
KB
-rw-r--r--
logging.html
95.64
KB
-rw-r--r--
mac.html
21.79
KB
-rw-r--r--
macos.html
14.76
KB
-rw-r--r--
macosa.html
12.96
KB
-rw-r--r--
macostools.html
15.52
KB
-rw-r--r--
macpath.html
7.76
KB
-rw-r--r--
mailbox.html
156.75
KB
-rw-r--r--
mailcap.html
13.21
KB
-rw-r--r--
markup.html
18.77
KB
-rw-r--r--
marshal.html
17.98
KB
-rw-r--r--
math.html
39.24
KB
-rw-r--r--
md5.html
13.97
KB
-rw-r--r--
mhlib.html
21.54
KB
-rw-r--r--
mimetools.html
19.25
KB
-rw-r--r--
mimetypes.html
28.39
KB
-rw-r--r--
mimewriter.html
15.02
KB
-rw-r--r--
mimify.html
13.36
KB
-rw-r--r--
miniaeframe.html
12.2
KB
-rw-r--r--
misc.html
6.87
KB
-rw-r--r--
mm.html
9.03
KB
-rw-r--r--
mmap.html
28.36
KB
-rw-r--r--
modulefinder.html
15.31
KB
-rw-r--r--
modules.html
8.46
KB
-rw-r--r--
msilib.html
52.43
KB
-rw-r--r--
msvcrt.html
19.37
KB
-rw-r--r--
multifile.html
24.3
KB
-rw-r--r--
multiprocessing.html
365.71
KB
-rw-r--r--
mutex.html
11.23
KB
-rw-r--r--
netdata.html
16.98
KB
-rw-r--r--
netrc.html
12.3
KB
-rw-r--r--
new.html
12.12
KB
-rw-r--r--
nis.html
10.64
KB
-rw-r--r--
nntplib.html
41.92
KB
-rw-r--r--
numbers.html
37.75
KB
-rw-r--r--
numeric.html
13.55
KB
-rw-r--r--
operator.html
82
KB
-rw-r--r--
optparse.html
222.56
KB
-rw-r--r--
os.html
214.25
KB
-rw-r--r--
os.path.html
38.34
KB
-rw-r--r--
ossaudiodev.html
41.5
KB
-rw-r--r--
othergui.html
9.08
KB
-rw-r--r--
parser.html
39.36
KB
-rw-r--r--
pdb.html
33.96
KB
-rw-r--r--
persistence.html
14.87
KB
-rw-r--r--
pickle.html
102.27
KB
-rw-r--r--
pickletools.html
10.63
KB
-rw-r--r--
pipes.html
18.01
KB
-rw-r--r--
pkgutil.html
25.11
KB
-rw-r--r--
platform.html
28.37
KB
-rw-r--r--
plistlib.html
17.03
KB
-rw-r--r--
popen2.html
25.43
KB
-rw-r--r--
poplib.html
22.32
KB
-rw-r--r--
posix.html
14.41
KB
-rw-r--r--
posixfile.html
19.76
KB
-rw-r--r--
pprint.html
29.92
KB
-rw-r--r--
profile.html
63.56
KB
-rw-r--r--
pty.html
9.48
KB
-rw-r--r--
pwd.html
11.43
KB
-rw-r--r--
py_compile.html
11.12
KB
-rw-r--r--
pyclbr.html
14.71
KB
-rw-r--r--
pydoc.html
11.48
KB
-rw-r--r--
pyexpat.html
71.53
KB
-rw-r--r--
python.html
12.27
KB
-rw-r--r--
queue.html
24.22
KB
-rw-r--r--
quopri.html
11.9
KB
-rw-r--r--
random.html
37.83
KB
-rw-r--r--
re.html
134.74
KB
-rw-r--r--
readline.html
28.24
KB
-rw-r--r--
repr.html
20.43
KB
-rw-r--r--
resource.html
26.48
KB
-rw-r--r--
restricted.html
11.65
KB
-rw-r--r--
rexec.html
37.41
KB
-rw-r--r--
rfc822.html
42.22
KB
-rw-r--r--
rlcompleter.html
13.51
KB
-rw-r--r--
robotparser.html
12.27
KB
-rw-r--r--
runpy.html
19.34
KB
-rw-r--r--
sched.html
18.54
KB
-rw-r--r--
scrolledtext.html
9.32
KB
-rw-r--r--
select.html
39.67
KB
-rw-r--r--
sets.html
36.92
KB
-rw-r--r--
sgi.html
9.71
KB
-rw-r--r--
sgmllib.html
30.77
KB
-rw-r--r--
sha.html
12.09
KB
-rw-r--r--
shelve.html
27.02
KB
-rw-r--r--
shlex.html
32.1
KB
-rw-r--r--
shutil.html
40.22
KB
-rw-r--r--
signal.html
31.14
KB
-rw-r--r--
simplehttpserver.html
18.41
KB
-rw-r--r--
simplexmlrpcserver.html
31.39
KB
-rw-r--r--
site.html
23.64
KB
-rw-r--r--
smtpd.html
12.46
KB
-rw-r--r--
smtplib.html
42.13
KB
-rw-r--r--
sndhdr.html
10.02
KB
-rw-r--r--
socket.html
106.34
KB
-rw-r--r--
socketserver.html
59.83
KB
-rw-r--r--
someos.html
15.11
KB
-rw-r--r--
spwd.html
10.33
KB
-rw-r--r--
sqlite3.html
139.5
KB
-rw-r--r--
ssl.html
65.62
KB
-rw-r--r--
stat.html
32.31
KB
-rw-r--r--
statvfs.html
10.6
KB
-rw-r--r--
stdtypes.html
260.4
KB
-rw-r--r--
string.html
106.65
KB
-rw-r--r--
stringio.html
18.81
KB
-rw-r--r--
stringprep.html
16.13
KB
-rw-r--r--
strings.html
14.93
KB
-rw-r--r--
struct.html
40.88
KB
-rw-r--r--
subprocess.html
84.91
KB
-rw-r--r--
sun.html
6.84
KB
-rw-r--r--
sunau.html
27.1
KB
-rw-r--r--
sunaudio.html
17.79
KB
-rw-r--r--
symbol.html
7.66
KB
-rw-r--r--
symtable.html
22.94
KB
-rw-r--r--
sys.html
98.7
KB
-rw-r--r--
sysconfig.html
23.84
KB
-rw-r--r--
syslog.html
17.92
KB
-rw-r--r--
tabnanny.html
10.63
KB
-rw-r--r--
tarfile.html
78.68
KB
-rw-r--r--
telnetlib.html
25.48
KB
-rw-r--r--
tempfile.html
29.42
KB
-rw-r--r--
termios.html
16.01
KB
-rw-r--r--
test.html
52.62
KB
-rw-r--r--
textwrap.html
27.25
KB
-rw-r--r--
thread.html
20.47
KB
-rw-r--r--
threading.html
76.69
KB
-rw-r--r--
time.html
56.93
KB
-rw-r--r--
timeit.html
36.27
KB
-rw-r--r--
tix.html
46.96
KB
-rw-r--r--
tk.html
23.64
KB
-rw-r--r--
tkinter.html
67.67
KB
-rw-r--r--
token.html
19.62
KB
-rw-r--r--
tokenize.html
18.45
KB
-rw-r--r--
trace.html
25.54
KB
-rw-r--r--
traceback.html
33.44
KB
-rw-r--r--
ttk.html
101.75
KB
-rw-r--r--
tty.html
9.06
KB
-rw-r--r--
turtle.html
211.74
KB
-rw-r--r--
types.html
27.59
KB
-rw-r--r--
undoc.html
23.16
KB
-rw-r--r--
unicodedata.html
18.55
KB
-rw-r--r--
unittest.html
202.85
KB
-rw-r--r--
unix.html
10.55
KB
-rw-r--r--
urllib.html
58.68
KB
-rw-r--r--
urllib2.html
100.58
KB
-rw-r--r--
urlparse.html
40.41
KB
-rw-r--r--
user.html
11.83
KB
-rw-r--r--
userdict.html
29.73
KB
-rw-r--r--
uu.html
11.03
KB
-rw-r--r--
uuid.html
28.19
KB
-rw-r--r--
warnings.html
46.6
KB
-rw-r--r--
wave.html
22.22
KB
-rw-r--r--
weakref.html
36.52
KB
-rw-r--r--
webbrowser.html
23.07
KB
-rw-r--r--
whichdb.html
8.85
KB
-rw-r--r--
windows.html
9.33
KB
-rw-r--r--
winsound.html
18.75
KB
-rw-r--r--
wsgiref.html
81.04
KB
-rw-r--r--
xdrlib.html
29.94
KB
-rw-r--r--
xml.dom.html
89.04
KB
-rw-r--r--
xml.dom.minidom.html
40.42
KB
-rw-r--r--
xml.dom.pulldom.html
12.71
KB
-rw-r--r--
xml.etree.elementtree.html
93.22
KB
-rw-r--r--
xml.html
16.49
KB
-rw-r--r--
xml.sax.handler.html
38.63
KB
-rw-r--r--
xml.sax.html
20.22
KB
-rw-r--r--
xml.sax.reader.html
39.09
KB
-rw-r--r--
xml.sax.utils.html
14.26
KB
-rw-r--r--
xmlrpclib.html
60.79
KB
-rw-r--r--
zipfile.html
53.14
KB
-rw-r--r--
zipimport.html
20.42
KB
-rw-r--r--
zlib.html
25.46
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : time.html
<!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="Content-Type" content="text/html; charset=utf-8" /> <title>15.3. time — Time access and conversions — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </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 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="15. Generic Operating System Services" href="allos.html" /> <link rel="next" title="15.4. argparse — Parser for command-line options, arguments and sub-commands" href="argparse.html" /> <link rel="prev" title="15.2. io — Core tools for working with streams" href="io.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <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="15.4. argparse — Parser for command-line options, arguments and sub-commands" accesskey="N">next</a> |</li> <li class="right" > <a href="io.html" title="15.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="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="allos.html" accesskey="U">15. Generic Operating System Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-time"> <span id="time-time-access-and-conversions"></span><h1>15.3. <a class="reference internal" href="#module-time" title="time: Time access and conversions."><tt class="xref py py-mod docutils literal"><span class="pre">time</span></tt></a> — Time access and conversions<a class="headerlink" href="#module-time" title="Permalink to this headline">¶</a></h1> <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."><tt class="xref py py-mod docutils literal"><span class="pre">datetime</span></tt></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."><tt class="xref py py-mod docutils literal"><span class="pre">calendar</span></tt></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> <ul class="simple" id="index-0"> <li>The <em class="dfn">epoch</em> is the point where the time starts. On January 1st of that year, at 0 hours, the “time since the epoch” is zero. For Unix, the epoch is 1970. To find out what the epoch is, look at <tt class="docutils literal"><span class="pre">gmtime(0)</span></tt>.</li> </ul> <ul class="simple" id="index-1"> <li>The functions in this module do 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 Unix, it is typically in 2038.</li> </ul> <ul class="simple" id="time-y2kissues"> <span id="index-2"></span><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. Functions accepting a <a class="reference internal" href="#time.struct_time" title="time.struct_time"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> (see below) generally require a 4-digit year. For backward compatibility, 2-digit years are supported if the module variable <tt class="docutils literal"><span class="pre">accept2dyear</span></tt> is a non-zero integer; this variable is initialized to <tt class="docutils literal"><span class="pre">1</span></tt> unless the environment variable <span class="target" id="index-3"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONY2K"><tt class="xref std std-envvar docutils literal"><span class="pre">PYTHONY2K</span></tt></a> is set to a non-empty string, in which case it is initialized to <tt class="docutils literal"><span class="pre">0</span></tt>. Thus, you can set <span class="target" id="index-4"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONY2K"><tt class="xref std std-envvar docutils literal"><span class="pre">PYTHONY2K</span></tt></a> to a non-empty string in the environment to require 4-digit years for all year input. When 2-digit years are accepted, they are converted according to the POSIX or X/Open standard: values 69-99 are mapped to 1969-1999, and values 0–68 are mapped to 2000–2068. Values 100–1899 are always illegal. Note that this is new as of Python 1.5.2(a2); earlier versions, up to Python 1.5.1 and 1.5.2a1, would add 1900 to year values below 1900.</li> </ul> <ul class="simple" id="index-5"> <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-6"> <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"><tt class="xref py py-func docutils literal"><span class="pre">time()</span></tt></a> and <a class="reference internal" href="#time.sleep" title="time.sleep"><tt class="xref py py-func docutils literal"><span class="pre">sleep()</span></tt></a> is better than their Unix equivalents: times are expressed as floating point numbers, <a class="reference internal" href="#time.time" title="time.time"><tt class="xref py py-func docutils literal"><span class="pre">time()</span></tt></a> returns the most accurate time available (using Unix <tt class="xref c c-func docutils literal"><span class="pre">gettimeofday()</span></tt> where available), and <a class="reference internal" href="#time.sleep" title="time.sleep"><tt class="xref py py-func docutils literal"><span class="pre">sleep()</span></tt></a> will accept a time with a nonzero fraction (Unix <tt class="xref c c-func docutils literal"><span class="pre">select()</span></tt> 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"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a>, <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a>, and <a class="reference internal" href="#time.strptime" title="time.strptime"><tt class="xref py py-func docutils literal"><span class="pre">strptime()</span></tt></a>, and accepted by <a class="reference internal" href="#time.asctime" title="time.asctime"><tt class="xref py py-func docutils literal"><span class="pre">asctime()</span></tt></a>, <a class="reference internal" href="#time.mktime" title="time.mktime"><tt class="xref py py-func docutils literal"><span class="pre">mktime()</span></tt></a> and <a class="reference internal" href="#time.strftime" title="time.strftime"><tt class="xref py py-func docutils literal"><span class="pre">strftime()</span></tt></a>, may be considered as a sequence of 9 integers. The return values of <a class="reference internal" href="#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a>, <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a>, and <a class="reference internal" href="#time.strptime" title="time.strptime"><tt class="xref py py-func docutils literal"><span class="pre">strptime()</span></tt></a> also offer attribute names for individual fields.</p> <p>See <a class="reference internal" href="#time.struct_time" title="time.struct_time"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> for a description of these objects.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.2: </span>The time value sequence was changed from a tuple to a <a class="reference internal" href="#time.struct_time" title="time.struct_time"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a>, with the addition of attribute names for the fields.</p> </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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> in UTC</td> <td><a class="reference internal" href="#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> in local time</td> <td><a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a></td> </tr> <tr class="row-even"><td><a class="reference internal" href="#time.struct_time" title="time.struct_time"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> in UTC</td> <td>seconds since the epoch</td> <td><a class="reference internal" href="calendar.html#calendar.timegm" title="calendar.timegm"><tt class="xref py py-func docutils literal"><span class="pre">calendar.timegm()</span></tt></a></td> </tr> <tr class="row-odd"><td><a class="reference internal" href="#time.struct_time" title="time.struct_time"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> in local time</td> <td>seconds since the epoch</td> <td><a class="reference internal" href="#time.mktime" title="time.mktime"><tt class="xref py py-func docutils literal"><span class="pre">mktime()</span></tt></a></td> </tr> </tbody> </table> </li> </ul> <p>The module defines the following functions and data items:</p> <dl class="data"> <dt id="time.accept2dyear"> <tt class="descclassname">time.</tt><tt class="descname">accept2dyear</tt><a class="headerlink" href="#time.accept2dyear" title="Permalink to this definition">¶</a></dt> <dd><p>Boolean value indicating whether two-digit year values will be accepted. This is true by default, but will be set to false if the environment variable <span class="target" id="index-7"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONY2K"><tt class="xref std std-envvar docutils literal"><span class="pre">PYTHONY2K</span></tt></a> has been set to a non-empty string. It may also be modified at run time.</p> </dd></dl> <dl class="data"> <dt id="time.altzone"> <tt class="descclassname">time.</tt><tt class="descname">altzone</tt><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 <tt class="docutils literal"><span class="pre">daylight</span></tt> is nonzero.</p> </dd></dl> <dl class="function"> <dt id="time.asctime"> <tt class="descclassname">time.</tt><tt class="descname">asctime</tt><big>(</big><span class="optional">[</span><em>t</em><span class="optional">]</span><big>)</big><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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> representing a time as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a> or <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a> to a 24-character string of the following form: <tt class="docutils literal"><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></tt>. If <em>t</em> is not provided, the current time as returned by <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a> is used. Locale information is not used by <a class="reference internal" href="#time.asctime" title="time.asctime"><tt class="xref py py-func docutils literal"><span class="pre">asctime()</span></tt></a>.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Unlike the C function of the same name, there is no trailing newline.</p> </div> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.1: </span>Allowed <em>t</em> to be omitted.</p> </dd></dl> <dl class="function"> <dt id="time.clock"> <tt class="descclassname">time.</tt><tt class="descname">clock</tt><big>(</big><big>)</big><a class="headerlink" href="#time.clock" title="Permalink to this definition">¶</a></dt> <dd><p id="index-8">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, but in any case, this is the function to use for benchmarking Python or timing algorithms.</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 <tt class="xref c c-func docutils literal"><span class="pre">QueryPerformanceCounter()</span></tt>. The resolution is typically better than one microsecond.</p> </dd></dl> <dl class="function"> <dt id="time.ctime"> <tt class="descclassname">time.</tt><tt class="descname">ctime</tt><big>(</big><span class="optional">[</span><em>secs</em><span class="optional">]</span><big>)</big><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"><tt class="xref py py-const docutils literal"><span class="pre">None</span></tt></a>, the current time as returned by <a class="reference internal" href="#time.time" title="time.time"><tt class="xref py py-func docutils literal"><span class="pre">time()</span></tt></a> is used. <tt class="docutils literal"><span class="pre">ctime(secs)</span></tt> is equivalent to <tt class="docutils literal"><span class="pre">asctime(localtime(secs))</span></tt>. Locale information is not used by <a class="reference internal" href="#time.ctime" title="time.ctime"><tt class="xref py py-func docutils literal"><span class="pre">ctime()</span></tt></a>.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.1: </span>Allowed <em>secs</em> to be omitted.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.4: </span>If <em>secs</em> is <a class="reference internal" href="constants.html#None" title="None"><tt class="xref py py-const docutils literal"><span class="pre">None</span></tt></a>, the current time is used.</p> </dd></dl> <dl class="data"> <dt id="time.daylight"> <tt class="descclassname">time.</tt><tt class="descname">daylight</tt><a class="headerlink" href="#time.daylight" title="Permalink to this definition">¶</a></dt> <dd><p>Nonzero if a DST timezone is defined.</p> </dd></dl> <dl class="function"> <dt id="time.gmtime"> <tt class="descclassname">time.</tt><tt class="descname">gmtime</tt><big>(</big><span class="optional">[</span><em>secs</em><span class="optional">]</span><big>)</big><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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></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"><tt class="xref py py-const docutils literal"><span class="pre">None</span></tt></a>, the current time as returned by <a class="reference internal" href="#time.time" title="time.time"><tt class="xref py py-func docutils literal"><span class="pre">time()</span></tt></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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> object. See <a class="reference internal" href="calendar.html#calendar.timegm" title="calendar.timegm"><tt class="xref py py-func docutils literal"><span class="pre">calendar.timegm()</span></tt></a> for the inverse of this function.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.1: </span>Allowed <em>secs</em> to be omitted.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.4: </span>If <em>secs</em> is <a class="reference internal" href="constants.html#None" title="None"><tt class="xref py py-const docutils literal"><span class="pre">None</span></tt></a>, the current time is used.</p> </dd></dl> <dl class="function"> <dt id="time.localtime"> <tt class="descclassname">time.</tt><tt class="descname">localtime</tt><big>(</big><span class="optional">[</span><em>secs</em><span class="optional">]</span><big>)</big><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"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a> but converts to local time. If <em>secs</em> is not provided or <a class="reference internal" href="constants.html#None" title="None"><tt class="xref py py-const docutils literal"><span class="pre">None</span></tt></a>, the current time as returned by <a class="reference internal" href="#time.time" title="time.time"><tt class="xref py py-func docutils literal"><span class="pre">time()</span></tt></a> is used. The dst flag is set to <tt class="docutils literal"><span class="pre">1</span></tt> when DST applies to the given time.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.1: </span>Allowed <em>secs</em> to be omitted.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.4: </span>If <em>secs</em> is <a class="reference internal" href="constants.html#None" title="None"><tt class="xref py py-const docutils literal"><span class="pre">None</span></tt></a>, the current time is used.</p> </dd></dl> <dl class="function"> <dt id="time.mktime"> <tt class="descclassname">time.</tt><tt class="descname">mktime</tt><big>(</big><em>t</em><big>)</big><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"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a>. Its argument is the <a class="reference internal" href="#time.struct_time" title="time.struct_time"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> or full 9-tuple (since the dst flag is needed; use <tt class="docutils literal"><span class="pre">-1</span></tt> 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"><tt class="xref py py-func docutils literal"><span class="pre">time()</span></tt></a>. If the input value cannot be represented as a valid time, either <a class="reference internal" href="exceptions.html#exceptions.OverflowError" title="exceptions.OverflowError"><tt class="xref py py-exc docutils literal"><span class="pre">OverflowError</span></tt></a> or <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></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.sleep"> <tt class="descclassname">time.</tt><tt class="descname">sleep</tt><big>(</big><em>secs</em><big>)</big><a class="headerlink" href="#time.sleep" title="Permalink to this definition">¶</a></dt> <dd><p>Suspend execution 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"><tt class="xref py py-func docutils literal"><span class="pre">sleep()</span></tt></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> </dd></dl> <dl class="function"> <dt id="time.strftime"> <tt class="descclassname">time.</tt><tt class="descname">strftime</tt><big>(</big><em>format</em><span class="optional">[</span>, <em>t</em><span class="optional">]</span><big>)</big><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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> representing a time as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a> or <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></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"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a> is used. <em>format</em> must be a string. <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> is raised if any field in <em>t</em> is outside of the allowed range.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.1: </span>Allowed <em>t</em> to be omitted.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.4: </span><a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> raised if a field in <em>t</em> is out of range.</p> <p class="versionchanged"> <span class="versionmodified">Changed in version 2.5: </span>0 is now 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"><tt class="xref py py-func docutils literal"><span class="pre">strftime()</span></tt></a> result:</p> <table border="1" class="docutils"> <colgroup> <col width="22%" /> <col width="64%" /> <col width="14%" /> </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><tt class="docutils literal"><span class="pre">%a</span></tt></td> <td>Locale’s abbreviated weekday name.</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%A</span></tt></td> <td>Locale’s full weekday name.</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%b</span></tt></td> <td>Locale’s abbreviated month name.</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%B</span></tt></td> <td>Locale’s full month name.</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%c</span></tt></td> <td>Locale’s appropriate date and time representation.</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%d</span></tt></td> <td>Day of the month as a decimal number [01,31].</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%H</span></tt></td> <td>Hour (24-hour clock) as a decimal number [00,23].</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%I</span></tt></td> <td>Hour (12-hour clock) as a decimal number [01,12].</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%j</span></tt></td> <td>Day of the year as a decimal number [001,366].</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%m</span></tt></td> <td>Month as a decimal number [01,12].</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%M</span></tt></td> <td>Minute as a decimal number [00,59].</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%p</span></tt></td> <td>Locale’s equivalent of either AM or PM.</td> <td>(1)</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%S</span></tt></td> <td>Second as a decimal number [00,61].</td> <td>(2)</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%U</span></tt></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><tt class="docutils literal"><span class="pre">%w</span></tt></td> <td>Weekday as a decimal number [0(Sunday),6].</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%W</span></tt></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><tt class="docutils literal"><span class="pre">%x</span></tt></td> <td>Locale’s appropriate date representation.</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%X</span></tt></td> <td>Locale’s appropriate time representation.</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%y</span></tt></td> <td>Year without century as a decimal number [00,99].</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%Y</span></tt></td> <td>Year with century as a decimal number.</td> <td> </td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">%Z</span></tt></td> <td>Time zone name (no characters if no time zone exists).</td> <td> </td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">%%</span></tt></td> <td>A literal <tt class="docutils literal"><span class="pre">'%'</span></tt> 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"><tt class="xref py py-func docutils literal"><span class="pre">strptime()</span></tt></a> function, the <tt class="docutils literal"><span class="pre">%p</span></tt> directive only affects the output hour field if the <tt class="docutils literal"><span class="pre">%I</span></tt> directive is used to parse the hour.</li> <li>The range really is <tt class="docutils literal"><span class="pre">0</span></tt> to <tt class="docutils literal"><span class="pre">61</span></tt>; this accounts for leap seconds and the (very rare) double leap seconds.</li> <li>When used with the <a class="reference internal" href="#time.strptime" title="time.strptime"><tt class="xref py py-func docutils literal"><span class="pre">strptime()</span></tt></a> function, <tt class="docutils literal"><span class="pre">%U</span></tt> and <tt class="docutils literal"><span class="pre">%W</span></tt> 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-9"></span><a class="rfc reference external" href="http://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-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">time</span> <span class="kn">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="s">"%a, </span><span class="si">%d</span><span class="s"> %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.</p> <p>On some platforms, an optional field width and precision specification can immediately follow the initial <tt class="docutils literal"><span class="pre">'%'</span></tt> of a directive in the following order; this is also not portable. The field width is normally 2 except for <tt class="docutils literal"><span class="pre">%j</span></tt> where it is 3.</p> </dd></dl> <dl class="function"> <dt id="time.strptime"> <tt class="descclassname">time.</tt><tt class="descname">strptime</tt><big>(</big><em>string</em><span class="optional">[</span>, <em>format</em><span class="optional">]</span><big>)</big><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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a> as returned by <a class="reference internal" href="#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a> or <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></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"><tt class="xref py py-func docutils literal"><span class="pre">strftime()</span></tt></a>; it defaults to <tt class="docutils literal"><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></tt> which matches the formatting returned by <a class="reference internal" href="#time.ctime" title="time.ctime"><tt class="xref py py-func docutils literal"><span class="pre">ctime()</span></tt></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#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> is raised. The default values used to fill in any missing data when more accurate values cannot be inferred are <tt class="docutils literal"><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></tt>.</p> <p>For example:</p> <div class="highlight-python"><div class="highlight"><pre><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="s">"30 Nov 00"</span><span class="p">,</span> <span class="s">"</span><span class="si">%d</span><span class="s"> %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 <tt class="docutils literal"><span class="pre">%Z</span></tt> directive is based on the values contained in <tt class="docutils literal"><span class="pre">tzname</span></tt> and whether <tt class="docutils literal"><span class="pre">daylight</span></tt> 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 <tt class="docutils literal"><span class="pre">strftime()</span></tt> is implemented per platform it can sometimes offer more directives than those listed. But <tt class="docutils literal"><span class="pre">strptime()</span></tt> 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><tt class="descclassname">time.</tt><tt class="descname">struct_time</tt><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"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></a>, <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a>, and <a class="reference internal" href="#time.strptime" title="time.strptime"><tt class="xref py py-func docutils literal"><span class="pre">strptime()</span></tt></a>. It is an object with a <a class="reference internal" href="../glossary.html#term-named-tuple"><em class="xref std std-term">named tuple</em></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><tt class="xref py py-attr docutils literal"><span class="pre">tm_year</span></tt></td> <td>(for example, 1993)</td> </tr> <tr class="row-odd"><td>1</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_mon</span></tt></td> <td>range [1, 12]</td> </tr> <tr class="row-even"><td>2</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_mday</span></tt></td> <td>range [1, 31]</td> </tr> <tr class="row-odd"><td>3</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_hour</span></tt></td> <td>range [0, 23]</td> </tr> <tr class="row-even"><td>4</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_min</span></tt></td> <td>range [0, 59]</td> </tr> <tr class="row-odd"><td>5</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_sec</span></tt></td> <td>range [0, 61]; see <strong>(2)</strong> in <a class="reference internal" href="#time.strftime" title="time.strftime"><tt class="xref py py-func docutils literal"><span class="pre">strftime()</span></tt></a> description</td> </tr> <tr class="row-even"><td>6</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_wday</span></tt></td> <td>range [0, 6], Monday is 0</td> </tr> <tr class="row-odd"><td>7</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_yday</span></tt></td> <td>range [1, 366]</td> </tr> <tr class="row-even"><td>8</td> <td><tt class="xref py py-attr docutils literal"><span class="pre">tm_isdst</span></tt></td> <td>0, 1 or -1; see below</td> </tr> </tbody> </table> <p class="versionadded"> <span class="versionmodified">New in version 2.2.</span></p> <p>Note that unlike the C structure, the month value is a range of [1, 12], not [0, 11]. A year value will be handled as described under <a class="reference internal" href="#time-y2kissues"><em>Year 2000 (Y2K) issues</em></a> above. A <tt class="docutils literal"><span class="pre">-1</span></tt> argument as the daylight savings flag, passed to <a class="reference internal" href="#time.mktime" title="time.mktime"><tt class="xref py py-func docutils literal"><span class="pre">mktime()</span></tt></a> will usually result in the correct daylight savings state to be 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"><tt class="xref py py-class docutils literal"><span class="pre">struct_time</span></tt></a>, or having elements of the wrong type, a <a class="reference internal" href="exceptions.html#exceptions.TypeError" title="exceptions.TypeError"><tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt></a> is raised.</p> </dd></dl> <dl class="function"> <dt id="time.time"> <tt class="descclassname">time.</tt><tt class="descname">time</tt><big>(</big><big>)</big><a class="headerlink" href="#time.time" title="Permalink to this definition">¶</a></dt> <dd><p>Return the time in seconds since the epoch as a floating point number. 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> </dd></dl> <dl class="data"> <dt id="time.timezone"> <tt class="descclassname">time.</tt><tt class="descname">timezone</tt><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).</p> </dd></dl> <dl class="data"> <dt id="time.tzname"> <tt class="descclassname">time.</tt><tt class="descname">tzname</tt><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.</p> </dd></dl> <dl class="function"> <dt id="time.tzset"> <tt class="descclassname">time.</tt><tt class="descname">tzset</tt><big>(</big><big>)</big><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-10"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TZ</span></tt> specifies how this is done.</p> <p class="versionadded"> <span class="versionmodified">New in version 2.3.</span></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-11"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TZ</span></tt> environment variable may affect the output of functions like <a class="reference internal" href="#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">localtime()</span></tt></a> without calling <a class="reference internal" href="#time.tzset" title="time.tzset"><tt class="xref py py-func docutils literal"><span class="pre">tzset()</span></tt></a>, this behavior should not be relied on.</p> <p class="last">The <span class="target" id="index-12"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TZ</span></tt> environment variable should contain no whitespace.</p> </div> <p>The standard format of the <span class="target" id="index-13"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TZ</span></tt> environment variable is (whitespace added for clarity):</p> <div class="highlight-python"><pre>std offset [dst [offset [,start[/time], end[/time]]]]</pre> </div> <p>Where the components are:</p> <dl class="docutils"> <dt><tt class="docutils literal"><span class="pre">std</span></tt> and <tt class="docutils literal"><span class="pre">dst</span></tt></dt> <dd>Three or more alphanumerics giving the timezone abbreviations. These will be propagated into time.tzname</dd> <dt><tt class="docutils literal"><span class="pre">offset</span></tt></dt> <dd>The offset has the form: <tt class="docutils literal"><span class="pre">±</span> <span class="pre">hh[:mm[:ss]]</span></tt>. 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><tt class="docutils literal"><span class="pre">start[/time],</span> <span class="pre">end[/time]</span></tt></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><tt class="samp docutils literal"><span class="pre">J</span><em><span class="pre">n</span></em></tt></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><tt class="samp docutils literal"><em><span class="pre">n</span></em></tt></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><tt class="samp docutils literal"><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></tt></dt> <dd>The <em>d</em>‘th day (0 <= <em>d</em> <= 6) or 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 Sunday.</dd> </dl> <p class="last"><tt class="docutils literal"><span class="pre">time</span></tt> has the same format as <tt class="docutils literal"><span class="pre">offset</span></tt> 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-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s">'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="s">'</span><span class="si">%X</span><span class="s"> </span><span class="si">%x</span><span class="s"> %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="s">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s">'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="s">'</span><span class="si">%X</span><span class="s"> </span><span class="si">%x</span><span class="s"> %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-14"></span><tt class="xref std std-envvar docutils literal"><span class="pre">TZ</span></tt> environment variable to the path of the required timezone datafile, relative to the root of the systems ‘zoneinfo’ timezone database, usually located at <tt class="file docutils literal"><span class="pre">/usr/share/zoneinfo</span></tt>. For example, <tt class="docutils literal"><span class="pre">'US/Eastern'</span></tt>, <tt class="docutils literal"><span class="pre">'Australia/Melbourne'</span></tt>, <tt class="docutils literal"><span class="pre">'Egypt'</span></tt> or <tt class="docutils literal"><span class="pre">'Europe/Amsterdam'</span></tt>.</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s">'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="s">'TZ'</span><span class="p">]</span> <span class="o">=</span> <span class="s">'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 class="admonition-see-also 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."><tt class="xref py py-mod docutils literal"><span class="pre">datetime</span></tt></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."><tt class="xref py py-mod docutils literal"><span class="pre">locale</span></tt></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"><tt class="xref py py-func docutils literal"><span class="pre">strftime()</span></tt></a> and <a class="reference internal" href="#time.strptime" title="time.strptime"><tt class="xref py py-func docutils literal"><span class="pre">strptime()</span></tt></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."><tt class="xref py py-mod docutils literal"><span class="pre">calendar</span></tt></a></dt> <dd>General calendar-related functions. <tt class="xref py py-func docutils literal"><span class="pre">timegm()</span></tt> is the inverse of <a class="reference internal" href="#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">gmtime()</span></tt></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 <tt class="docutils literal"><span class="pre">%Z</span></tt> is now deprecated, but the <tt class="docutils literal"><span class="pre">%z</span></tt> 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-15"></span><a class="rfc reference external" href="http://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-16"></span><a class="rfc reference external" href="http://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-17"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc1123.html"><strong>RFC 1123</strong></a> and then mandated by <span class="target" id="index-18"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>.</td></tr> </tbody> </table> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="io.html" title="previous chapter">15.2. <tt class="docutils literal"><span class="pre">io</span></tt> — Core tools for working with streams</a></p> <h4>Next topic</h4> <p class="topless"><a href="argparse.html" title="next chapter">15.4. <tt class="docutils literal"><span class="pre">argparse</span></tt> — Parser for command-line options, arguments and sub-commands</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/time.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input 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> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <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="15.4. argparse — Parser for command-line options, arguments and sub-commands" >next</a> |</li> <li class="right" > <a href="io.html" title="15.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="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="allos.html" >15. Generic Operating System Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
Close