473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

php displaying last modification time

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
4 8685
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: fowlertrainer | last post by:
Hi ! I want to change the "modification time" attribute of a file, after download - from python. But I don't find any function that do this. If it is don't exists in python, please write an...
3
by: nathan_kent_bullock | last post by:
Assume I am using a class Foo. I want to find out the modification time of the file that that class was defined in. How would I go about this? If I could find out the name of the file that Foo...
3
by: beliavsky | last post by:
Using Python 2.4 on Windows, for me the command print os.stat("temp.txt") gives 1115478343 , which is "seconds since the epoch". How can I get the modification time in a format such as
6
by: pg | last post by:
Is there any simple way to query the most recent time of "changes" made to a table? I'm accessing my database with ODBC to a remote site thru internet. I want to eliminate some DUPLICATE long...
6
by: Gregor Kovač | last post by:
Hi! I'm using DB2 v8.2.2 on Windows. Is there a way to know when a table was last modified (ALTER TABLE). There is create time for the table in SYSCAT.TABLES, but I have not seen modification...
1
by: mich dobelman | last post by:
How can i just get the last modification date from the header list. I though I can $request->headers to get the modification date, but without success. <?php include( "Snoopy.class.php" );...
9
by: Hemant Shah | last post by:
How do I find out when the table was modified? When I look at syscat.tables it only lists creation time. -- Hemant Shah /"\ ASCII ribbon campaign E-mail:...
3
by: MarcJoseph | last post by:
I have a database that is shared my multiple users who enter and update records on a weekly basis. Is there a way I can add a field to my main data table that will automatically generate the...
3
by: pramodkh | last post by:
Hi All, I have a remote directory wherein some files will be generated. I am writting a PERL script in windows to get the latest file created in that directory.How do i achieve this? This is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.