Answers for "how to convert time from one timezone to another in python"

0

how to convert time from one timezone to another in python

from datetime import datetime
from pytz import timezone
format = "%Y-%m-%d %H:%M:%S %Z%z"
# Current time in UTC
now_utc = datetime.now(timezone('UTC'))
print(now_utc.strftime(format))
# Convert to Asia/Kolkata time zone
now_asia = now_utc.astimezone(timezone('Asia/Kolkata'))
print(now_asia.strftime(format))
Posted by: Guest on August-31-2020
0

how to convert time from one timezone to another in python

$ pip install pytz
Posted by: Guest on August-31-2020

Code answers related to "how to convert time from one timezone to another in python"

Python Answers by Framework

Browse Popular Code Answers by Language