Over a million developers have joined DZone.

Time Module

·

>>> from time import time, localtime, strftime
>>> time()             # seconds since the epoch
1135156165.5569999
>>> localtime()[0:3]   # date
(2005, 12, 21)
>>> localtime()[3:6]   # time
(16, 9, 27)
>>> strftime("%d %b %Y %H:%M:%S", localtime())
'21 Dec 2005 16:09:27'
>>>
See more detail in python documentation
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}