Reputation: 16829
How can I display the last time the current document was updated in PHP?
Upvotes: 2
Views: 4375
Reputation: 400922
If by "current document", you mean "script that is currently being executed", you can use something like this :
$timestamp = filemtime(__FILE__);
$date = date('Y-m-d H:i:s', $timestamp);
var_dump($date);
And the output is like :
string '2009-08-27 20:17:54' (length=19)
Which is the date and time it is right now in France ;-)
See filemtime
to get the last modification date of a file, and date and it's formatting options to convert the timestamp returned by filemtime
to something a human-being can understand.
Upvotes: 7
Reputation: 268324
filemtime(); // file modified time
Example from PHP.net,
<?php
// outputs e.g. somefile.txt was last modified: December 29 2002 22:16:23.
$file= 'somefile.txt';
if (file_exists($file)) {
echo "$file was last modified: " . date ("F d Y H:i:s.", filemtime($file));
}
?>
Upvotes: 3