file mtime

file mtime name ?time?

Returns a decimal string giving the time at which file name was last modified. If time is specified, it is a modification time to set for the file (equivalent to Unix touch). The time is measured in the standard POSIX fashion as seconds from a fixed starting time (often January 1, 1970). If the file doesn't exist or its modified time cannot be queried or set then an error is generated.


See also


Random Verbiage Discussion Starts Here (AKA Old Crap)

LV Recently I was told by a Tcl programmer that they could not use file mtime on a Windows system because it didn't return the right value after DST took place.

I was surprised - I hadn't heard of that, and wasn't certain exactly what the implications of that might be. Is this something that experienced Windows programmers just know?

LV 2009 Jul 28 Well, I have no idea to what the Tcl programmer was referring. Perhaps it was some limitation in an older version of Tcl. However, using Tcl 8.5.7 on Windows XP, I was able to do this:

tclsh
% touch abc
% clock format [file mtime abc]
Tue Jul 28 12:01:32 -0400 2009
%

which was the time that I was running this stuff. So it looks like recent Tcl releases do not have this issue.

MiR - 2009-07-28 04:06:42

The Daylight Saving Time problem is common on Windows Systems, as the timestamps are saved not as UST values. In fact, Windows handles DST like changing the absolute system time, not as applying a timezone to it.

MHo 2018-05-18: I noticed that a tcl 8.6.8 starkit cannot show the modification time of a directory within it's own virtual file system, while at the same time a mtime of a dir in a mounted ZIP-file is shown.