Skip to content

Instantly share code, notes, and snippets.

@arbinish
Created June 26, 2018 08:59
Show Gist options
  • Save arbinish/045b304f78f76502a4f332f841b2faaf to your computer and use it in GitHub Desktop.
Save arbinish/045b304f78f76502a4f332f841b2faaf to your computer and use it in GitHub Desktop.
python timezone conversion
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