By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,550 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,550 IT Pros & Developers. It's quick & easy.

php displaying last modification time

P: n/a
Hello,
Trying to get a php script to display when a web page was last modified.
My code is below, i'm getting a last modified date of dec. 31 1969 which is
wrong for one, and does not change if i modify the resulting file. The code
itself is in an include file, a footer file, which will be included at the
bottom of every page. Suggestions?
Thanks.
Dave.

<?

echo "This file was last modified: ";

$temp = pathinfo($PHP_SELF);

echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

?>
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
dave wrote:
Hello,
Trying to get a php script to display when a web page was last modified. [...]
<?

echo "This file was last modified: ";

$temp = pathinfo($PHP_SELF);
Maybe the error is here. Do you have register_globals = on?
If not, this should work for you:
$temp = pathinfo($SERVER['PHP_SELF']);

echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

?>


HTH,

Till
Jul 17 '05 #2

P: n/a
Till Glöggler wrote:
dave wrote:
Hello,
Trying to get a php script to display when a web page was last
modified. [...]

<?

echo "This file was last modified: ";

$temp = pathinfo($PHP_SELF);


Maybe the error is here. Do you have register_globals = on?
If not, this should work for you:
$temp = pathinfo($SERVER['PHP_SELF']);


this should be $_SERVER['PHP_SELF'] (note the underscore before SERVER)
Jul 17 '05 #3

P: n/a
Hello,
My thanks to everyone who helped with my last modification time issue.
In summary i did not have register_globals on and the code now is:

<?

echo "This file was last modified: ";

$temp = pathinfo($_SERVER['PHP_SELF']);

echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

?>

Hope this helps someone and again thanks for the assist.

Dave.


Jul 17 '05 #4

P: n/a
Use $_SERVER['SCRIPT_FILENAME'] instead. PHP_SELF is the URI of the running
script. Your script would fail if some of letters in URI are in the wrong
case.

Uzytkownik "dave" <dm*******@woh.rr.com> napisal w wiadomosci
news:iP****************@fe2.columbus.rr.com...
Hello,
Trying to get a php script to display when a web page was last modified. My code is below, i'm getting a last modified date of dec. 31 1969 which is wrong for one, and does not change if i modify the resulting file. The code itself is in an include file, a footer file, which will be included at the
bottom of every page. Suggestions?
Thanks.
Dave.

<?

echo "This file was last modified: ";

$temp = pathinfo($PHP_SELF);

echo strftime("%A %B %d, %Y", filemtime($temp["basename"]));

?>

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.