Created
February 13, 2017 17:32
-
-
Save jbfuzier/7ee6ecdb716f8bb69c8555b437abef08 to your computer and use it in GitHub Desktop.
Python Timezone conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dateutil import tz | |
tzone = tz.gettz('Europe/Paris') | |
utc = tz.gettz('UTC') | |
# Make datetime object timezone aware | |
datetime_local = datetime_local.replace(tzinfo=tzone) | |
# Do the timezone change | |
date_utc = datetime_local.astimezone(utc) | |
# Epoch timestamp to timezone aware datetime | |
datetime.datetime.utcfromtimestamp(time).replace(tzinfo=utc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://pypi.python.org/pypi/python-dateutil