Jun-30-2023, 07:09 AM
To verify:
from datetime import datetime, date, time, timedelta from pytz import timezone time_today_KL = datetime.combine(date.today(), time(), tzinfo=timezone("Asia/Kuala_Lumpur")) # Time now in Kuala_Lumpur t_start_KL = time_today_KL - timedelta(hours=24) # Start time t_end_KL = t_start_KL + timedelta(hours=24) # End time t_start_KL = t_start_KL.timestamp() t_end_KL = t_end_KL.timestamp() print(datetime.fromtimestamp(t_start_KL), datetime.fromtimestamp(t_end_KL))This will print the start and stop times in Seattle (or wherever you are when you run this script). Check the printout against your expectations.