DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Time Module

12.21.2005
| 17614 views |
  • submit to reddit
        
>>> 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 <a href=http://docs.python.org/lib/module-time.html>python documentation</a>