Created
June 26, 2018 08:59
-
-
Save arbinish/045b304f78f76502a4f332f841b2faaf 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
import pytz | |
from datetime import datetime | |
utcnow = datetime.utcnow() | |
# localized (with tzinfo) version | |
localized_utcnow = pytz.utc.localize(utcnow) | |
# find pacific time | |
pacific = pytz.timezone('US/Pacific') | |
pacific.normalize(localize_utcnow) | |
# find India standard time | |
ist = pytz.timezone('Asia/Kolkata') | |
ist.normalize(localize_utcnow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment