Friday, June 21, 2013

Convert time Object to datetime Objects

Here is a quick snippet to convert a time object to a datetime object.

import time
import datetime
gmt_time_object = time.gmtime()
dt = datetime.datetime.fromtimestamp(time.mktime(gmt_time_object))

Now you have a datetime object from a time object.
Enjoy

No comments: