October 30th, 2015

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.

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.