#as an aware datetime
from datetime import datetime, timezone
utc_dt = datetime.now(timezone.utc) # UTC time
dt = utc_dt.astimezone() # local time
#or from pytz database
import pytz
tz = pytz.timezone('Europe/Berlin')
berlin_now = datetime.now(tz)
import datetime
now = datetime.datetime.now()
local_now = now.astimezone()
local_tz = local_now.tzinfo
local_tzname = local_tz.tzname(local_now)
print(local_tzname)
import pytz
from datetime import datetime
tz = pytz.timezone('Asia/Kathmandu')
datetime = datetime.now()
new_date = tz.localize(datetime)
from time import gmtime, strftime
print(strftime("%z", gmtime()))
from datetime import datetime
import pytz
local = datetime.now()
print("Local:", local.strftime("%m/%d/%Y, %H:%M:%S"))
tz_NY = pytz.timezone('America/New_York')
datetime_NY = datetime.now(tz_NY)
print("NY:", datetime_NY.strftime("%m/%d/%Y, %H:%M:%S"))
tz_London = pytz.timezone('Europe/London')
datetime_London = datetime.now(tz_London)
print("London:", datetime_London.strftime("%m/%d/%Y, %H:%M:%S"))