1

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?

2 Answers2

1

Use os.stat("/").st_ctime_ns gain nanoseconds level

import os
import datetime

datetime.datetime.fromtimestamp(os.stat("/").st_ctime_ns)
Arduino_Sentinel
  • 819
  • 11
  • 21
0

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.

Pierre Barre
  • 2,174
  • 1
  • 11
  • 23