file mtime

Gives the time of the last change of a file, in seconds.

file mtime NAME

Description

Gives the time of the last change of the content of NAME, in seconds since 1970-01-01 UTC. A missing file is an error. A new time as a second argument is an error in ztcl.

Arguments

ArgumentTypeDefaultDescription
NAMEpathrequiredThe path.

Returns

An integer of seconds.

Examples

% set f [open n.txt w]; close $f
> expr {[file mtime n.txt] > 0}
1

Errors

% file mtime nope.txt
could not read "nope.txt": no such file or directory
-errorcode POSIX ENOENT {no such file or directory}

% file mtime n.txt 1700000000
file mtime with a new time is not available
-errorcode NONE

Differences from Tcl

Facts

Capability
file. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also