Page 1 of 1
Display the date/timestamp of a file
Posted: Sat Nov 13, 2004 3:37 pm
by paulpechey
I want to dynamically display the date that my web pages were updated, and figure I should be able to retrieve the date/timestamp of the file as a PHP variable, and then display it. However, I can't seem to find out how to do this anywhere. Can anyone help?
Posted: Sat Nov 13, 2004 3:39 pm
by scorphus
[php_man]stat[/php_man]()
Posted: Sat Nov 13, 2004 3:44 pm
by djot
-
Hi,
If it should be the real date of a real file modified this is the way to get the filetime:
Code: Select all
<?php
// outputs e.g. somefile.txt was last modified: December 29 2002 22:16:23.
$filename = 'somefile.txt';
if (file_exists($filename)) {
echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>
*source:
http://www.php.net/manual/en/function.filemtime.php
djot
-