0

I am trying to get only the date in a certain format from a file. I was able to get it working using the following code, but it gives the time, as well as the formatting is incorrect.

Any help would be appreciated.

Code

modDate = os.stat(fPath).st_mtime
        print(datetime.fromtimestamp(modDate))

Output:

2018-03-01 15:48:30.149375

dwb
  • 475
  • 6
  • 31
  • 1
    Why are you expecting that to only print the date? And what format is expected? – jhpratt Dec 07 '18 at 20:23
  • @jhpratt I did not expect the above code to display only the date. I tried other code, such as datetime.date, and all that resulted in errors. To prevent confusion I reverted the code to the above. All I am trying to get from the output is the date in the format MM-DD-YYYY – dwb Dec 07 '18 at 20:26

0 Answers0