PHP ZipArchive: how to fix inaccurate file dates?

43 Views Asked by At

I have a php (7.0.33) script that zips a whole web directory, complete with sub-folders & files. After downloading and extracting such an archive, I noticed that the file dates from within the zip are all shifted by 2 hours (and 1 second) compared with the respective file dates from the server, which happens to be my time zone's offset (UTC/GMT +2 hours).

I need the dates to be accurate.

So it looks like a time zone issue, but I cannot see how I could fix it. I have read that ZipArchive doesn't support timezone settings...?

So I thought I might use the setMtimeIndex() method from ZipArchive: https://www.php.net/manual/en/ziparchive.setmtimeindex.php to set proper file dates while zipping them. But the server states that the method is undefined. The documentation specifies that the method is available starting from Libzip ≥ 1.0.0. My server has Libzip 1.1.2, so...?

Any ideas? Thanks! :)

0

There are 0 best solutions below