Reputation:
After some research I couldn't find any solution to this so here it goes:
Python's command:
time.ctime(os.path.getctime('/path'))
displays output as (e.g):
Fri Dec 2 16:06:05 2016
.
How can I make it display not only hours/minutes/seconds but also milliseconds?
Upvotes: 1
Views: 3386
Reputation: 819
Use os.stat("/").st_ctime_ns
gain nanoseconds level
import os
import datetime
datetime.datetime.fromtimestamp(os.stat("/").st_ctime_ns)
Upvotes: 1
Reputation: 2174
You can use stat
:
import datetime
import os
datetime.datetime.fromtimestamp(os.stat('/').st_ctime)
Note that if you modified the metadata of the file, you will get this as the "ctime", getting the creation date after modification of metadata is not possible on UNIX platforms.
Upvotes: 0