How can I create a file with invalid Windows timestamps?

4

I'd like to create a file with an invalid created/modified/accessed timestamp. To be invalid it should be a date and time before 12:00 midnight January 1, 1601 C.E. UTC

Tom Robinson

Posted 2010-10-07T12:17:41.380

Reputation: 2 350

Why would you want to do this? – Rowland Shaw – 2010-10-07T12:28:42.773

2So that I can test that the application I'm writing can handle corrupt timestamps gracefully. – Tom Robinson – 2010-10-07T12:30:32.207

Answers

3

Look for a tool called Timestomp

The software's goal is to allow for the deletion or modification of time stamp-related information on files.

bob

Posted 2010-10-07T12:17:41.380

Reputation: 46

6

This is not possible.

File time is used in Windows API through the FILETIME Structure, described as:

Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).

As negative values are not supported, the above date is the starting limit.

Conclusion: Your code which tests for earlier dates will never be challenged.

harrymc

Posted 2010-10-07T12:17:41.380

Reputation: 306 093

2The "touch" command in Linux can create such a file, but under Windows it is recognized as being created today. (Tested with FAT32 Flashdrive and Win XP) – None – 2010-10-07T14:03:49.377