Skip to content

Instantly share code, notes, and snippets.

@joonro
Last active March 27, 2020 22:42
Show Gist options
  • Save joonro/5f079e2571f4ca199dd429b070ee5644 to your computer and use it in GitHub Desktop.
Save joonro/5f079e2571f4ca199dd429b070ee5644 to your computer and use it in GitHub Desktop.
[Python dealing with UTC timestamps] 2020-03-27 It seems this method is accurate because it explicitly specifies UTC time. #pyhton #time
import datetime
# get UTC timestamp in seconds
datetime_utc_origin = datetime.datetime(1970, 1, 1)
# now
utc_timestamp_now = (datetime.datetime.utcnow() - datetime_utc_origin).total_seconds()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment