Why does the timestamp of a file increase by up to 2 seconds when I put it in a ZIP archive, then extract it?
We saw some time ago that the timestamp of a file increases by up to 2 seconds when you copy it to a USB thumb drive. The underlying reason is that USB thumb drives tend to be formatted with the FAT file system, and the FAT file system records timestamps in local time to only two-second resolution.
The same logic applies to ZIP archives. The ZIP archive format records file times in MS-DOS format, so it too is subject to the two-second resolution limitation.
And the reason the time increases to the nearest two-second interval rather than rounding is so that files do not go backward in time. This is useful when you freshen a ZIP archive: If the file time went backward, then the freshen operation would always report that there were files that needed to be updated.
From the point of view of time stamps, the ZIP archive acts like a tiny FAT-formatted USB thumb drive.
Bonus chatter: If you want to copy files whose timestamps are newer, but take into account MS-DOS timestamp rounding, you can use the
robocopy command with the
/FFT command line options.