Assuming the file exists (using os.path.exists(filename)
to first make sure that it does), how do I display the time a file was last modified? This is on Linux if that makes any difference.
Using getlastmod() Function: The getlastmod() function is used to get the last modification time of the current page.
The File. lastModified read-only property provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
Method 1: Get file creation & modification date or time in Python using the time module. We will use getctime() and getmtime() function found inside the path module in the os library, for getting the creation and modification times of the file.
>>> import os >>> f = os.path.getmtime('test1.jpg') >>> f 1223995325.0
since the beginning of (epoch)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With