To get the creation time of a file, you can use os.path.getctime (file_path) on Windows. On UNIX systems, you cannot use the same function that returns the last time a file’s attributes or content was changed. To get the creation time on UNIX-based systems, use the st_birthtime attribute of the stat tuple.
On Windows &
""" import os""" print os.path.getctime (’my_file’) 1505928271.0689342
This gives the time in seconds since the beginning of the epoch. For UNIX systems,
import os stat = os.stat (path_to_file) try: print (stat.st_birthtime) except AttributeError: # Probably on Linux. No easy way to get creation dates here, # so we’ll settle for when its content was last modified. print (stat.st_mtime)
This will give output &
You can use os.path.getmtime (path) to get the modification time of a file. Cross-platform supported.
""" import os""" print os.path.getmtime (’my_file’) 1505928275.3081832