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

前端 未结 2 499
梦毁少年i
梦毁少年i 2020-11-29 19:15

I seem to have a hard time getting my head around this.

What\'s the difference between calendar.timegm() and time.mktime()?

Say I h

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 19:45

    calendar.timegm converts from UTC timestamp, time.mktime converts from local time not UTC.

    8 hours difference in their results corresponds exactly to timezone of your location.

提交回复
热议问题