datetime tzinfo get hour python astimezone code example

Example 1: python calculate computation time

import time 
begin = time.time()
''' your script here '''
time.sleep(1)  # store end time 
end = time.time()  # total time taken 
print(f"Total runtime of the program is {end - begin}") 
# https://www.geeksforgeeks.org/python-measure-time-taken-by-program-to-execute/

Example 2: datetime python timezone

import datetime
import pytz
my_date = datetime.datetime.now(pytz.timezone('US/Pacific'))

Example 3: python set timezone of datetime.now

my_date = datetime.datetime.now(pytz.timezone('US/Pacific'))