This is how you can find out when a file was modified in PHP.
1. filemtime
$filename = "reademe.txt"; if (file_exists($filename)) { echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename)); }
php filemtime reference here
2. stat[‘mtime’]
$stat = stat("reademe.txt"); if (is_array($stat)) { echo 'Modification time: ' . date ("F d Y H:i:s.", $stat['mtime']); }
php stat reference here
Note that both filemtime and stat[‘mtime’] returns a unix timestamp which is not very useful for normal human brain consumption so mosf of the time you will need to convert it to a human understandable date format using the php date function (see examples above)
Leave a Reply