Python – calendar.timegm() vs. time.mktime()

time.mktime() assumes that the passed tuple is in local time, calendar.timegm() assumes it’s in GMT/UTC. Depending on the interpretation the tuple represents a different time, so the functions return different values (seconds since the epoch are UTC based).

The difference between the values should be equal to the time zone offset of your local time zone.

Leave a Comment