killerbng icon

File Creation Times

killerbng | PRO | 01/03/17 02:22:54 AM UTC | 0 ⭐ | 254 👁️ | Never ⏰ | []
Python |

460 B

|

None

|

0 👍

/

0 👎

import os
import platform
import datetime
 
def creation_date(path_to_file):
    if platform.system() == 'Windows':
        return os.path.getctime(path_to_file)
    else:
        stat = os.stat(path_to_file)
        try:
            return stat.st_birthtime
        except AttributeError:
            return stat.st_mtime
 
def unix_time_to_readable(ctime, format="'%Y-%m-%d %H:%M:%S'"):
    return datetime.datetime.fromtimestamp(int(ctime)).strftime(format)

Comments