Python: Get Current Date Time in Different Time Zone

In this tutorial, we will use an example to show you how to get current date time in different time zone using python.

Python - Get Current Date Time in Different Time Zone

1.Import library

from datetime import datetime
import pytz

2.Get time inĀ  New York

New_York = pytz.timezone('America/New_York')
New_York_date_time = datetime.now(New_York)
print("New York time is:", New_York_date_time.strftime("%H:%M:%S"))

3.Get time in London right now

London = pytz.timezone('Europe/London')
London_date_and_Time = datetime.now(London)
print("London time is :", London_date_and_Time.strftime("%H:%M:%S"))

Run this code, you will get two different time:

New York time is: 13:59:58
London time is : 18:59:58