pytz library
- Install
pytz
library from the command line:
pip install pytz
- Convert date and time from one time zone to another:
import datetime
import pytz
dateTimeFormat = '%Y-%m-%d %H:%M:%S'
tz = pytz.timezone('America/New_York')
dt = datetime.datetime.now(tz)
dateTime = dt.strftime(dateTimeFormat)
print(dateTime)
Leave a Comment
Cancel reply