Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ touch somefile.txt # Create file
- $ sleep 10
- $ touch -a somefile.txt # Update file's access time (causes a metadata update if done this way)
- $ echo 'import os, time, datetime
- file = "somefile.txt"
- print(file)
- print("Modified")
- print(os.stat(file)[-2])
- print(os.stat(file).st_mtime)
- print(os.path.getmtime(file))
- print()
- print("Created")
- print(os.stat(file)[-1])
- print(os.stat(file).st_ctime)
- print(os.path.getctime(file))
- print()
- modified = os.path.getmtime(file)
- print("Date modified: "+time.ctime(modified))
- print("Date modified:",datetime.datetime.fromtimestamp(modified))
- year,month,day,hour,minute,second=time.localtime(modified)[:-3]
- print("Date modified: %02d/%02d/%d %02d:%02d:%02d"%(day,month,year,hour,minute,second))
- print()
- created = os.path.getctime(file)
- print("Date created: "+time.ctime(created))
- print("Date created:",datetime.datetime.fromtimestamp(created))
- year,month,day,hour,minute,second=time.localtime(created)[:-3]
- print("Date created: %02d/%02d/%d %02d:%02d:%02d"%(day,month,year,hour,minute,second))' | python3
- somefile.txt
- Modified
- 1578600831
- 1578600831.4016254
- 1578600831.4016254
- Created
- 1578600867
- 1578600867.805996
- 1578600867.805996
- Date modified: Thu Jan 9 21:13:51 2020
- Date modified: 2020-01-09 21:13:51.401625
- Date modified: 09/01/2020 21:13:51
- Date created: Thu Jan 9 21:14:27 2020
- Date created: 2020-01-09 21:14:27.805996
- Date created: 09/01/2020 21:14:27
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement