Hi,
does anyone understand the timezone conversions?
I found I cannot see the "real" timestamps of the files in a share in Asia when I mount it to my server in Pacific NW.
I thought I can do the following and it will give me the results I want but it did not.
thank you.
does anyone understand the timezone conversions?
I found I cannot see the "real" timestamps of the files in a share in Asia when I mount it to my server in Pacific NW.
I thought I can do the following and it will give me the results I want but it did not.
Code:
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}")
for file in folder.iterdir():
mtime = file.stat().st_mtime
if t_start_KL <= mtime < t_end_KL :
print(file.name, mtime, datetime.fromtimestamp(mtime))