Jun-30-2023, 05:45 AM
Greetings!
Just to make sure I do (and understand) it correctly.
I need to collect all files with a yesterday timestamp from Asia Kuala Lumpur hosts.
I’m going to run my script every day at 11 AM (US/Pacific), in Kuala Lumpur it’ll be the next day 2 AM.
It means I need to find yesterday's start-end time in Kuala Lumpur.
Here is a snipped I come up with based on the code shared by 'deanhystad' :
Please advise...
Thank you!
Just to make sure I do (and understand) it correctly.
I need to collect all files with a yesterday timestamp from Asia Kuala Lumpur hosts.
I’m going to run my script every day at 11 AM (US/Pacific), in Kuala Lumpur it’ll be the next day 2 AM.
It means I need to find yesterday's start-end time in Kuala Lumpur.
Here is a snipped I come up with based on the code shared by 'deanhystad' :
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(f" Start time={t_start_KL}, End time={t_end_KL}")It looks ok to me but it is not the first time when I'm making mistakes...
Please advise...
Thank you!