On this page
calendar.timegm
Prev: calendar.TextCalendar | Up: calendar | Next: calendar.weekday
Rel: calendar.calendar, calendar.Calendar, calendar.Day, calendar.firstweekday
Ref: docs.python.org — calendar.timegm
Tags: #public #python3 #stdlib #calendar
Import
import calendar
from calendar import timegm
Signature & Overview
calendar.timegm(tuple)
Unrelated but handy function to calculate Unix timestamp from GMT.
Usage
import calendar
import time
assert calendar.timegm((1970, 1, 1, 0, 0, 0)) == 0
assert calendar.timegm(time.gmtime(1_700_000_000)) == 1_700_000_000
Gotchas
- UTC inverse of
time.gmtime(): Unliketime.mktime(),timegm()never applies local timezone offsets.
REPL Inspect
from calendar import timegm
help(timegm)
Linked from
Related notes
- tuts/python3/stdlib_module/calendar/TextCalendar Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/weekday Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/calendar Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Calendar_class Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Day Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/firstweekday Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/calendar/HTMLCalendar shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalMonthError shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalWeekdayError shared tags: #calendar, #stdlib