mercredi 14 août 2013

[Python] convert timestamp -> datetime -> timestamp


#convert a date to a timestamp
def convert_to_timestamp(dt):
    return calendar.timegm(dt.utctimetuple())

#convert a timestamp to a datetime

def convert_to_date(timestamp_long):
    return datetime.datetime.utcfromtimestamp(timestamp_long)



Aucun commentaire:

Categories