Advertisements

*a constant parallactic paradox, sublime*

Python “time” Module

>>> import time
>>> now = time.strftime("%Y-%m-%d %H:%M:%S")
>>> now
'2009-10-28 14:10:52'
>>> tup = time.strptime(now, "%Y-%m-%d %H:%M:%S")
>>> tup
(2009, 10, 28, 14, 10, 52, 2, 301, -1)
>>> unix = time.mktime(tup)
>>> unix
1256710252.0
>>> tup2 = time.gmtime(unix) 
>>> tup2 == tup
False
>>> tup
(2009, 10, 28, 14, 10, 52, 2, 301, -1)
>>> tup2
(2009, 10, 28, 6, 10, 52, 2, 301, 0)
>>> time.strftime("%Y-%m-%d %H:%M:%S", tup)
'2009-10-28 06:10:52'
>>> time.strftime("%Y-%m-%d %H:%M:%S", tup2)
'2009-10-28 06:10:52'

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s