File size: 643 Bytes
5acc411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import platform
import datetime

def get_creation_date(path):
    # if platform.system() == 'Windows':
        # return datetime.datetime.fromtimestamp(os.path.getctime(path))
    # else:
        # # On Linux/Unix, return last metadata change time
        stat = os.stat(path)
        print(stat)
        # try:
            # return datetime.datetime.fromtimestamp(stat.st_birthtime)  # macOS
        # except AttributeError:
            # Linux fallback
        return datetime.datetime.fromtimestamp(stat.st_ctime)

# Example
file_path = "run_lora_chat.py"
print("Creation time:", get_creation_date(file_path))