You can use the os.path.getctime()
method to get the creation time of a directory in Python. This method returns the timestamp of the creation time of the file or directory in seconds since the epoch. You can then convert this timestamp to a readable format using the datetime
module.
Here's an example code snippet that demonstrates how to find the creation date of a directory in Python:
main.py352 chars14 lines
Replace /path/to/directory
with the actual path of the directory you want to check. The code will print the creation time of the directory in the following format:
Directory '/path/to/directory' was created on YYYY-MM-DD HH:MM:SS.ssssss
.
gistlibby LogSnag