Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File dates

0 views
Skip to first unread message

Barely Audible

unread,
Oct 25, 2009, 7:42:27 AM10/25/09
to
I've changed my web server to a new machine and setup. Previously I was
using the following at the bottom of html pages to show the file
creation/last modified date....

<script>
<!--
document.write("<center>");
document.write("<FONT COLOR=#ffffff>");
document.write("This page was last updated on "+document.lastModified);
document.write("</FONT>");
document.write("</center>");
// -->
</script>

which it did. However on the new machine it only shows the current date
& time. Obviously I have missed something iin the apache setup that will
make it display the the correct file creation/modification date - anyone
tell me what it is?

Many Thanks!

--
TTFN
Jim

"Life's tough......It's even tougher if you're stupid."
--John Wayne

Swifty

unread,
Oct 25, 2009, 1:07:19 PM10/25/09
to
Barely Audible wrote:
> I've changed my web server to a new machine and setup. Previously I was
> using the following at the bottom of html pages to show the file
> creation/last modified date....
>
> <script>
> <!--
> document.write("<center>");
> document.write("<FONT COLOR=#ffffff>");
> document.write("This page was last updated on "+document.lastModified);
> document.write("</FONT>");
> document.write("</center>");
> // -->
> </script>
>
> which it did. However on the new machine it only shows the current date
> & time. Obviously I have missed something iin the apache setup that will
> make it display the the correct file creation/modification date - anyone
> tell me what it is?

That's exactly the construct that I've been using for years
(document.lastModified) and it has worked across all versions of Apache
running under OS/2, Linux and Windows XP. I've never had to do anything
special with apache.

What do you get for the date and time when you display the file? One
thing that might cause this effect would be if you were somehow picking
up the date of last reference, but why this should be happening is a
mystery!

--
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk

Barely Audible

unread,
Oct 26, 2009, 3:29:41 AM10/26/09
to

I get the current date & time!

One thing I am beginning to suspect is that my pages now have php
embedded in them and I am wondering if the current date and time is
displayed because of the php generating stuff?


--
TTFN
Jim

A good plan violently executed today is better than a perfect plan
executed tomorrow.
-- George S. Patton

Ed Mullen

unread,
Oct 26, 2009, 11:04:49 AM10/26/09
to

Then you may want to use a PHP solution:

<?php
$last_modified = filemtime("map.html");
print(" Last changed: ");
print(date("F j, Y - h:i A", $last_modified));
?>


--
Ed Mullen
http://edmullen.net
Boycott shampoo! Demand the REAL poo!

Ian Pawson

unread,
Oct 27, 2009, 4:55:50 AM10/27/09
to
To make this a bit more generic, ie not having to enter the filename,
add this to you html code:-

<h4>Page last modified: <?=date ("j\<\s\u\p\>S\<\/\s\u\p\> F Y H:i:s",
getlastmod()); ?></h4>

Josiah Jenkins

unread,
Oct 27, 2009, 7:01:08 AM10/27/09
to

Excellent !

Any way of truncating the info to remove the timestamp ?
ie just show - 27th October 2009 - on the page.
--


http://www.ian-stewart.eu

Barely Audible

unread,
Oct 27, 2009, 10:26:12 AM10/27/09
to

Nice! I would have thought that just substituting it for the scrip
section would have worked but it just causes a dreaded white page error
- what have I missed here?

Barely Audible

unread,
Oct 27, 2009, 10:26:52 AM10/27/09
to

An even more elegant solution!

--
TTFN
Jim

"There is NO job in the Field Artillery for the weak, the
timid or the indecisive."
-- Unknown

Swifty

unread,
Oct 27, 2009, 10:35:01 AM10/27/09
to
Barely Audible wrote:
> Nice! I would have thought that just substituting it for the scrip
> section would have worked but it just causes a dreaded white page error
> - what have I missed here?

Most of my "White page errors" are because I have an unmatched quote, or
tag, such as:

<SCRIPT SRC=/debug.js><SCRIPT>

Ed Mullen

unread,
Oct 27, 2009, 11:00:19 AM10/27/09
to
Ian Pawson wrote:
> Ed Mullen wrote:

>>
>> Then you may want to use a PHP solution:
>>
>> <?php
>> $last_modified = filemtime("map.html");
>> print(" Last changed: ");
>> print(date("F j, Y - h:i A", $last_modified));
>> ?>
>>
>>
> To make this a bit more generic, ie not having to enter the filename,
> add this to you html code:-
>
> <h4>Page last modified:<?=date ("j\<\s\u\p\>S\<\/\s\u\p\> F Y H:i:s",
> getlastmod()); ?></h4>

Nice! Interesting tidbit though. It works on my online server (PHP
version 4.4.9) but not on my local server (PHP v. 5.2.6). Locally it
just displays - Page last modified: followed by the PHP code.

"An ounce of practice is worth more than tons of preaching." - Mohandas
Gandhi

Ed Mullen

unread,
Oct 27, 2009, 11:06:36 AM10/27/09
to
Ed Mullen wrote:
> Ian Pawson wrote:
>> Ed Mullen wrote:
>
>>>
>>> Then you may want to use a PHP solution:
>>>
>>> <?php
>>> $last_modified = filemtime("map.html");
>>> print(" Last changed: ");
>>> print(date("F j, Y - h:i A", $last_modified));
>>> ?>
>>>
>>>
>> To make this a bit more generic, ie not having to enter the filename,
>> add this to you html code:-
>>
>> <h4>Page last modified:<?=date ("j\<\s\u\p\>S\<\/\s\u\p\> F Y H:i:s",
>> getlastmod()); ?></h4>
>
> Nice! Interesting tidbit though. It works on my online server (PHP
> version 4.4.9) but not on my local server (PHP v. 5.2.6). Locally it
> just displays - Page last modified: followed by the PHP code.
>

After looking it up I'm guessing it doesn't work on my local machine
because it's Windows, not Linux/Unix as my online server.

If it weren't for the gutter, my mind would be homeless.

Ed Mullen

unread,
Oct 27, 2009, 11:09:39 AM10/27/09
to
Barely Audible wrote:
> <script>
> <!--
> document.write("<center>");
> document.write("<FONT COLOR=#ffffff>");
> document.write("This page was last updated on "+document.lastModified);
> document.write("</FONT>");
> document.write("</center>");
> // -->
> </script>

Not sure. Do you have a URL for a test page we could look at?

Does the name Pavlov ring a bell?

Ian Pawson

unread,
Oct 27, 2009, 12:34:39 PM10/27/09
to

Just remove the H:i:s from the formatting string to remove the time and
remove the S and the <sup></sup> from jS to stop the th after the day
number if you don't want that bit.

Ed Mullen

unread,
Oct 27, 2009, 1:51:48 PM10/27/09
to
Ed Mullen wrote:
> Ed Mullen wrote:
>> Ian Pawson wrote:
>>> Ed Mullen wrote:
>>
>>>>
>>>> Then you may want to use a PHP solution:
>>>>
>>>> <?php
>>>> $last_modified = filemtime("map.html");
>>>> print(" Last changed: ");
>>>> print(date("F j, Y - h:i A", $last_modified));
>>>> ?>
>>>>
>>>>
>>> To make this a bit more generic, ie not having to enter the filename,
>>> add this to you html code:-
>>>
>>> <h4>Page last modified:<?=date ("j\<\s\u\p\>S\<\/\s\u\p\> F Y H:i:s",
>>> getlastmod()); ?></h4>
>>
>> Nice! Interesting tidbit though. It works on my online server (PHP
>> version 4.4.9) but not on my local server (PHP v. 5.2.6). Locally it
>> just displays - Page last modified: followed by the PHP code.
>>
>
> After looking it up I'm guessing it doesn't work on my local machine
> because it's Windows, not Linux/Unix as my online server.

I did a test page using the three different methods: The OP's
javascript, the one I suggested using filemtime and Ian's using
getlastmod. I just checked the page about an hour and twenty minutes
after uploading it to my host (Linux). The other two times are correct
but the javascript version shows the current time (same problem as OP had).

http://edmullen.net/root_example.php

Refresh the page and you'll see what it's doing. Wonder what's up with
that.

Why can't women put on mascara with their mouth closed?

Ed Mullen

unread,
Oct 27, 2009, 1:58:58 PM10/27/09
to

Interesting. The page displays identically in: SeaMonkey 2, Firefox 3
and IE8.

In Opera 9.64 the javascript line says:

"Using javascript - This page was last updated on January 1, 1970 GMT" !!!

In Safari (Windows) 3 it says:

"Using javascript - This page was last updated on" - and, yes, I do have
javascript enabled in Safari. ;-)

When it rains, why don't sheep shrink?

Josiah Jenkins

unread,
Oct 27, 2009, 6:44:35 PM10/27/09
to
>Just remove the H:i:s from the formatting string to remove the time and
>remove the S and the <sup></sup> from jS to stop the th after the day
>number if you don't want that bit.

Thanks.
Exactly the way I wanted it.

<p><?=date ("jS\ F Y", getlastmod()); ?></p>

Dropped it straight into my PHP footer, job done.
--


http://www.ian-stewart.eu

0 new messages