I would like to get the creation date of a file inside zipped folder.
I know that without zip, this can be achieved with using os.path.getctime()
function and last modified date of a file inside zipped folder can be extracted with ZipInfo.date_time
. But ZipInfo
does not seem to have a way to extract the creation date.
Also, I have tried on using ZipInfo
to get the modified date as follows.
# zip_file is the .zip folder
# screenshot_filename is the file inside .zip
with ZipFile(zip_file, 'r') as my_zip:
my_zip.getinfo(screenshot_filename)
And the ZipInfo
object result does not contain any date_time
information. Below is the example.
<ZipInfo filename='SCREEN CAP/SS.png' compress_type=deflate external_attr=0x20 file_size=555790 compress_size=504859>
So, did I do it wrongly or is there any better way to extract the creation date (or modified date if creation date is not possible) of a file inside zipped folder?
UPDATE:
I got the answer to get the last modified time/date_time
from ZipInfo
. Apparently, although date_time
is not listed in the object, we can get it simply by accessing the attribute, i.e.
my_zip.getinfo(screenshot_filename).date_time
However, I am still looking for the answer for getting the creation date.