|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50678 files extracted by ZipArchive class lost their original modified time
Submitted: 2010-01-06 15:58 UTC Modified: 2015-05-20 22:41 UTC
Avg. Score:4.3 ± 0.8
Reproduced:16 of 16 (100.0%)
Same Version:7 (43.8%)
Same OS:11 (68.8%)
From: sunchaojun at gmail dot com Assigned:
Status: Analyzed Package: Zip Related
PHP Version: 5.6.9 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: sunchaojun at gmail dot com
New email:
PHP Version: OS:


 [2010-01-06 15:58 UTC] sunchaojun at gmail dot com
After I extract a zip file via ZipArchive class in my php codes, I found that the creation time, modified time and lastaccess time of the files extracted have been set to the time at that it was being extracted.

Reproduce code:
From manual page: class.ziparchive
$zip = new ZipArchive();
if ($zip->open('')) {

Expected result:
A extracted files has the same creation time, modified time and lastaccess time with its oringinal copy.

Actual result:
The creation time, modified time and lastaccess time of a extracted file has been reset when extracting.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-15 22:32 UTC] hardcorevenom at gmx dot de
PHP Version 5.2.13
Apache/2.2.3 (Scientific Linux)

ZipArchive::extractTo("dir") sets the dates of all extracted files to the current time. The original "mdate" stored in the zip archive is not restored as expected.
AFAIK last access and creation time is not stored in a zip file, only last modified. So access and creation time is currently set correctly.
 [2014-08-06 11:40 UTC] michaeld at owl-online dot de
sadly, it is still in there:  php 5.5.11 win and php 5.3.4 linux
 [2015-05-20 19:07 UTC]
-Status: Open +Status: Verified -PHP Version: 5.2.12 +PHP Version: 5.6.9
 [2015-05-20 19:07 UTC]
Verified for PHP 5.6.9.

> AFAIK last access and creation time is not stored in a zip file,
> [...]

The creation time can be stored in a ZIP file, but ZipArchive
doesn't do that.
 [2015-05-20 22:41 UTC]
-Status: Verified +Status: Analyzed
 [2015-05-20 22:41 UTC]
I have to correct myself. According to the PKWARE ZIP file format
specification [1], the only timestamp that is generally available
for files in an archive is the mtime. ctime and atime are only
supported for some host systems and available in extra fields,
which don't seem to be supported by libzip[2] at all.

To set the stored mtime when files are extracted, it seems to be
sufficient to retrieve it via zip_stat_index() and to touch the
files after extraction in php_zip_extract_file().

[1] <>
[2] <>
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Feb 21 01:01:26 2020 UTC