llm_for_Code / filetime.py
1earner1's picture
Upload filetime.py with huggingface_hub
5acc411 verified
Raw
History Blame Contribute Delete
643 Bytes
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))