SHOW:
|
|
- or go back to the newest paste.
| 1 | import os | |
| 2 | import platform | |
| 3 | import datetime | |
| 4 | ||
| 5 | def creation_date(path_to_file): | |
| 6 | if platform.system() == 'Windows': | |
| 7 | return os.path.getctime(path_to_file) | |
| 8 | else: | |
| 9 | stat = os.stat(path_to_file) | |
| 10 | try: | |
| 11 | return stat.st_birthtime | |
| 12 | except AttributeError: | |
| 13 | return stat.st_mtime | |
| 14 | ||
| 15 | def unix_time_to_readable(ctime, format="'%Y-%m-%d %H:%M:%S'"): | |
| 16 | return datetime.datetime.fromtimestamp(int(ctime)).strftime(format) |