javacript DateModified and PHP includes

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
I'm using a javascript which displays the date the page was last modified. It gets the date as shown below:

var modDate = new Date(Date.parse(document.lastModified));

What I keep finding though is that the date displayed is always the current date! I thought it mught at first be because I had the call for the javascript (external) in a PHP include. I changed that but it is still doing it.

I also have most of the contents in the <head> element as a PHP include. This inculdes the reference to the source of the js file. For now, I removed the reference for the JS file from the PHP include and left it in the <head> element.

I'm beginning to wonder though. If I use a PHP include, when the server puts the html together, does this count as modifying the file for the purposes of javascript?
Thanks,
 

jiml8

Guest
Joined
Jul 2, 2005
Messages
2,634
DrP said:
I'm beginning to wonder though. If I use a PHP include, when the server puts the html together, does this count as modifying the file for the purposes of javascript?
Thanks,
Think about it this way.

The web page does not exist - at all - until it is built by the server that is running the PHP program.
 
Joined
Jul 8, 2002
Messages
14,681
If you want to get what the filesystem reports as the last modification date, use filemtime() in PHP.
 

DrP

Thread Starter
Joined
Jul 23, 2005
Messages
739
I've recently changed it to:
<?php echo date( "d F Y", getlastmod() ); ?> which has printed today's date fine. I'll have to wait until tomorrow whether it gives the date the file was modified though.
What is the difference between that and filemtime() ?
 
Joined
Apr 30, 2005
Messages
3,012
DrP said:
I've recently changed it to:
<?php echo date( "d F Y", getlastmod() ); ?> which has printed today's date fine. I'll have to wait until tomorrow whether it gives the date the file was modified though.
What is the difference between that and filemtime() ?
That's what I do, but I also added the time
<?php
echo "Updated: ". date( "F d Y h:i:s A", getlastmod() );
?>
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top