Jun-30-2023, 10:54 PM
I haven't followed this thread carefully, but here is some basic datetime stuff.
myfile = '/home/pedro/temp/atext_1.txt' print('This file is', os.path.getsize(myfile), 'bytes big!') print('This file was modified on', os.path.getmtime(myfile)) print('This file was created on,', os.path.getctime(myfile)) print('This file was last accessed on,', os.path.getatime(myfile)) print(os.stat(myfile)) file_data = os.stat(myfile) for f in file_data: print(f) # get the creation time in seconds and as a date creation_time = file_data[-1] ct = datetime.fromtimestamp(creation_time) cd = ct.strftime("%B %d %Y %H:%M:%S") print('This file was created on', cd) # get the modified time in seconds and as a date modified_time = file_data[-2] mt = datetime.fromtimestamp(modified_time) md = mt.strftime("%B %d %Y %H:%M:%S") print('This file was modified on', md) # get the last accessed time in seconds and as a date lat = file_data[-3] latt = datetime.fromtimestamp(lat) latd = mt.strftime("%B %d %Y %H:%M:%S") print('This file was last accessed on', latd)I'm not sure where your files may be modified, in Malaysia or in America. But if you stick with UTC, that is irrelevant.