0

I am lost as to how to turn the time stamp into a formal date and how to format it.

import os
import datetime
    
def file_date(filename):
  # Create the file in the current directory
  with open(filename,'w') as file:
    #Create the timestamp
    timestamp = os.path.getmtime(filename)
  # Convert the timestamp into a readable format, then into a string
  date_time = datetime.datetime.fromtimestamp(timestamp)
  # Return just the date portion
  date = ______

  # Hint: how many characters are in “yyyy-mm-dd”? 10
  return ("{}".format(date))
    
print(file_date("newfile.txt")) 
# Should be today's date in the format of yyyy-mm-dd
qouify
  • 3,698
  • 2
  • 15
  • 26

0 Answers0