|
-
Apr 7th, 2004, 07:40 AM
#1
Thread Starter
Frenzied Member
date modified [Resolved]
I'm trying to put the date a file was modified on each page that I have but I want to put that in an included file (footer.php) and I'm using the following code:
PHP Code:
$modified = stat();
echo " " . date("l, F dS",$modified[9]);
Where the name of the file you're getting the stats on is the name of the current page you're on.
The problem is, all server variables that are available also contain the path to that file. How do I remove the folder/path name from the $_SERVER['SCRIPT_NAME'] call?
Or is there a better way to do this?
Last edited by ober0330; Apr 7th, 2004 at 09:06 AM.
-
Apr 7th, 2004, 09:05 AM
#2
Thread Starter
Frenzied Member
Got it:
PHP Code:
$tok = strtok($_SERVER['SCRIPT_NAME'], "/");
$sname = "";
while ($tok) {
if(trim($tok) != "")
$sname = $tok;
$tok = strtok("/");
}
$modified = stat($sname);
echo "<br>Procedure Modified: " . date("n/j/Y",$modified[9]);
-
Apr 7th, 2004, 09:12 AM
#3
<?="Moderator"?>
Found this have a look
PHP Code:
<?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));
}
?>
http://uk.php.net/manual/en/function.filemtime.php
-
Apr 7th, 2004, 09:38 AM
#4
Thread Starter
Frenzied Member
Thanks 
New code:
PHP Code:
$tok = strtok($_SERVER['SCRIPT_NAME'], "/");
while ($tok) {
if(trim($tok) != "")
$sname = $tok;
$tok = strtok("/");
}
echo "<br>Procedure Modified: " . date("n/j/Y",filemtime($sname));
-
Apr 7th, 2004, 10:20 AM
#5
Stuck in the 80s
Why loop when you don't have to?
PHP Code:
$sname = substr($_SERVER['SCRIPT_NAME'], strrpos($_SERVER['SCRIPT_NAME'], '/') + 1);
echo "<br>Procedure Modified: " . date("n/j/Y",filemtime($sname));
-
Apr 7th, 2004, 10:31 AM
#6
Thread Starter
Frenzied Member
ah ha... see... that's the solution I was looking for 
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|