my $atime = (stat "foo_dir")[8];
Or, if you'd like a nicer interface to stat,
use File::stat:
use File::stat;
my $stat = stat "foo_dir";
my $atime = $stat->atime;
Either of those will put the last accessed time,
in epoch seconds, into $atime. | [reply] [d/l] [select] |
Hi btrott,
I'm afraid your method doesn't always work... I've been wanting to retrieve last accessed time by using this method and even though it works fine with Win NT4, it fails with Win98 and 2000. It only returns the date when the folder was last accessed. Time is set to midnight (00:00:00) and the epoch stamp ends with 3 zeros.
As a matter of fact, if you have a look at the folder's properties by right-clicking on it, you won't get much further - it seems like the time property was forgotten altogether in Windows as far as access time is concerned (it still is there for modified time).
I'm much annoyed by this fact and don't really know how to get round this little glitch. I later found on a Windows website (http://windows.about.com/library/tips/bltip343.htm)that timestamping could be disabled on NTFS-based systems, but Win98 isn't one...
Furthermore last modified time is only updated when a file directly in the considered folder is changed/created/deleted ie if the folder you're looking at is c:\hello and c:\hello\good\win\test.htm is updated, then only good's modified timestamp will have changed (which we must admit isn't very logical).
is all hope lost ? Please help if you've any idea...
Originally posted as a Categorized Answer.
| [reply] |