I wish to get the date & timestamp of a unix directory; then get the current time; and finally calculate time elapsed since the directory has been written too.
I think i can get the directory date stamp with:
$dir_name="test_dir";
($WRITETIME)=(stat($dir_name))[9];
This I is believe gives me the epoch time.
I now need the current time (in epoch) so that I can subtract one from the other to work out the number of seconds since the directory has been written to.
How do I do this?
Any help would be much appreciated :0)
To get the current epoch time (seconds since 1970):
$now = time;
Example code (not tested):
@stats = stat($filename);
$filetime = $stats[9];
$now = time;
$difference = $now - $filetime;
print "File $filename last modified $difference seconds ago\n";
Regards,
R.