Posted on: 13 October 2011 in python, time, unix
>>> from datetime import date
>>> from time import mktime
>>> start = date(2011, 9, 26)
>>> mktime(start.timetuple())
1316991600.0
>>> from time import strftime
>>> from datetime import datetime
>>> datetime.fromtimestamp(int("1284101485")).strftime('%Y-%m-%d %H:%M:%S')
'2010-09-10 07:51:25'
Comments
If you would like to leave a comment then email me at ian@mulvany.net, and if I like it I'll add it to the post.