pytz is a Python module mostly used for resolving the issues related to time zone differences. This module determines the time of any region using the local timezone name taking UTC time as the reference. The datetime is a python built-in library.
Code:
from datetime import datetime
now=datetime.now()
current_time=now.strftime("%H:%M:%S")
print("Current time:",current_time)
#time object containing current time
now=datetime.now().time() #time object
print("Now:",now)
print("Type of now is",type(now))
import pytz
tz_NY=pytz.timezone("America/New_York")
datetime_NY=datetime.now(tz_NY)
print("NY time:",datetime_NY.strftime("%H:%M:%S"))
tz_London=pytz.timezone("Europe/London")
datetime_London=datetime.now(tz_London)
print("London time:",datetime_London.strftime("%H:%M:%S"))
On this page of the site you can watch the video online 43. Time Object and Time Zone in Python with Code || Date Time Module-III Programming Tutorial with a duration of hours minute second in good quality, which was uploaded by the user Bhavatavi 12 August 2022, share the link with friends and acquaintances, this video has already been watched 8 times on youtube and it was liked by 0 viewers. Enjoy your viewing!