Get creation time of file in milliseconds
Timestamp resolution
The creation timestamp of a file in windows depends on the file system:
FAT/VFAT has a maximum resolution of 2s
NTFS has a maximum resolution of 100 ns
wmic solution
You can use wmic
to retrieve the file creation date to the nearest microsecond.
Example:
F:\test>wmic datafile where name="f:\\test\\test.txt" get creationdate | findstr /brc:[0-9]
20150329221650.080654+060
The creationdate 20150329221650.080654+060
is a timestamp, with the following format:
yyyymmddHHMMSS.xxxxxxsUUU
where:
yyyy
Four-digit year (0000 through 9999).mm
Two-digit month (01 through 12).dd
Two-digit day of the month (01 through 31).HH
Two-digit hour of the day using the 24-hour clock (00 through 23).MM
Two-digit minute in the hour (00 through 59).SS
Two-digit number of seconds in the minute (00 through 59).xxxxxx
Six-digit number of microseconds in the second (000000 through 999999)s
Plus sign (+
) or minus sign (-
) to indicate a positive or negative offset from Coordinated Universal Times (UTC).UUU
Three-digit offset indicating the number of minutes that the originating time zone deviates from UTC.
stat solution
You can also use stat
(from a cygwin or mingw installation).
Example:
DavidPostill@Hal /f/test
$ stat test.txt | grep Birth
Birth: 2015-03-29 22:16:50.080654200 +0100
dir output for comparison
F:\test>dir /t:c test.txt
Volume in drive F is Expansion
Volume Serial Number is 3656-BB63
Directory of F:\test
29/03/2015 22:16 32 test.txt
1 File(s) 32 bytes
0 Dir(s) 1,798,546,849,792 bytes free
Further Reading
- wmic
- Working with Dates and Times using WMI
- An A-Z Index of the Windows CMD command line is an excellent reference for all things Windows cmd line related.