how to convert time from one timezone to another in python

Solutions on MaxInterview for how to convert time from one timezone to another in python by the best coders in the world

showing results for - "how to convert time from one timezone to another in python"
Alan
14 Jul 2018
1from datetime import datetime
2from pytz import timezone
3format = "%Y-%m-%d %H:%M:%S %Z%z"
4# Current time in UTC
5now_utc = datetime.now(timezone('UTC'))
6print(now_utc.strftime(format))
7# Convert to Asia/Kolkata time zone
8now_asia = now_utc.astimezone(timezone('Asia/Kolkata'))
9print(now_asia.strftime(format))
Elisha
21 Jun 2019
1$ pip install pytz
queries leading to this page
convert to datetime and apply timezone pythonchange in between timezones pythonhow to get the current timezone in python and convert to other country timezonehow to convert datetime into specific timezone pythonpython datetime for different timezonesconvert to timezone pythonconvert time zones pythonpython convert datetime timezonehow to convert datetime to specific timezone in pythonchange date to other timezone pythonconvert datetime timezone to another timezoneconvert datetime to another timezone pythonconvert several timezones to one pythondatetime in one timezone to other pythonhow to use datetime for different timezones pythonconvert timestamp to other timezone in pythonpython datetime why day 2b one if timezoneconvert timezone in pythonpython convert datetime to another timezonehow to get different timezone in pythonhow to convert time to other timzone pythonpython convert timezonepython convert datetime to specific timezonepython convert to timezonepython datetime convert from one timezone to anotherpython convert date to another timezoneconvert ist to gmt in pythonpython convert to timezone from gmttimezone convertion in pythonhow to convert datetime object to different timezone pythonhow to handle different timezone values in pythonconvert time from one timezone to another in pythonconvert to given timezone pythonpython change time to different timezoneconvert timezone to local time pythonhow to get different timezone pythontimezone get timestamp pythonpython datetime to another timezonepython sql timestamp with timezonehow to convert datetime to specific timezone pythondatetime python convert from one timezone to anotherpython datetime transform to another timezoneconvert datetime from one timezone to another pythonconvert datetime to different timezone pythontimezone utc to timezone ist convert in pythonpython convert from one timezone to anotherchange time according to timezone pythonpytz convert to other timezoneconvert between timezones pythondatetime in timezone to another timezone pythonconvert timestamp timezone pythonadd two timezones pythontimezone conversion in pythonpython timestamp with timezoneget the difference between two timezone pythonpython timestamp convert timezonehow to convert time to some timezone pythonhow to convert time from one timezone to another in pythonpython convert to another timezone python3how to convert time from one timezone to another in python