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

document.lastModified

P: n/a
Hi. How to do document.lastModified works with Netscape and Opera ? Or
what other way to take to simply display the last update date about
current page ?
Nov 23 '05 #1
Share this Question
Share on Google+
17 Replies


P: n/a
VK

JellyON wrote:
Hi. How to do document.lastModified works with Netscape and Opera ? Or
what other way to take to simply display the last update date about
current page ?


document.lastModified supported since JavaScript 1.0 by all ever
existed / existing browsers (including Netscape and Opera) - so I don't
see where could be any problem.

If you are looking for a way to display the date nicely on the page,
then something like:

<html>
<head>
<title>Last Modified</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">

<script type="text/javascript">

function showLastModified() {
var out = document.getElementById('lastModified');
var d = new Date();
if (d.toLocaleDateString) {
out.innerHTML = d.toLocaleDateString(document.lastModified);
}
else {
out.innerHTML = document.lastModified;
}
}

window.onload = showLastModified;
</script>

</head>

<body>

<p id="lastModified">&nbsp;</p>

</body>
</html>

Nov 23 '05 #2

P: n/a
VK wrote on 15 nov 2005 in comp.lang.javascript:
document.lastModified supported since JavaScript 1.0 by all ever
existed / existing browsers (including Netscape and Opera) - so I don't
see where could be any problem.


A warning should be in place,
that "asp-pages" [and probably also "php-pages"]
are constructed/rendered HTML new(!!!!) every time,
so that the ever changing document.lastModified,
while being correct, is not very usefull.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 23 '05 #3

P: n/a
VK

Evertjan. wrote:
A warning should be in place,
that "asp-pages" [and probably also "php-pages"]
are constructed/rendered HTML new(!!!!) every time,
so that the ever changing document.lastModified,
while being correct, is not very usefull.


A good point!
I guess formally it's correct (?) because document.lastModified
indicates when the *content* of document has been last time changed.
And in case of ASP it happened during the parsing on the server-side.
Maybe it's time to introduce some new property like
lastTemplateModified ? :-)

Microsoft suggests in such case to set Last-Modified header explicetly
in the server response:
<http://support.microsoft.com/kb/q165862/>

Seems like a nice workaround?

Nov 23 '05 #4

P: n/a
VK wrote on 15 nov 2005 in comp.lang.javascript:

Evertjan. wrote:
A warning should be in place,
that "asp-pages" [and probably also "php-pages"]
are constructed/rendered HTML new(!!!!) every time,
so that the ever changing document.lastModified,
while being correct, is not very usefull.
A good point!
I guess formally it's correct (?) because document.lastModified
indicates when the *content* of document has been last time changed.
And in case of ASP it happened during the parsing on the server-side.
Maybe it's time to introduce some new property like
lastTemplateModified ? :-)


I like that.
Microsoft suggests in such case to set Last-Modified header explicetly
in the server response:
<http://support.microsoft.com/kb/q165862/>


No, that is only for older IIS versions giving an unreadable value:

"SYMPTOMS
The lastModified property that the Internet Explorer HTML scripting
object model exposes indicates the date and time at which the sender
believes the resource was last modified. When this property is referenced
in a page that the Active Server Page (ASP) framework generates, the
client browser displays an unreadable value."

The date is stil refreshed every time.

http://www.tutorial-web.com/asp/fso/...teLastModified

FSO can find the date serverside, I hope, and then the header could be
set as indicated by MS?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 23 '05 #5

P: n/a
JellyON wrote:
Hi. How to do document.lastModified works with Netscape and Opera ?
It works within the limits of transmitted HTTP headers. Nothing has to
be done.
Or what other way to take to simply display the last update date about
current page ?


Use reliable server-side scripting, not unreliable client-side one,
e.g. Server-side JavaScript, ASP with JScript or, as here, PHP:

<?php echo date('Y-m-d\TH:i:sO', @filemtime($sFile)); ?>

where $sFile is the filename string or a constant like `__FILE__'.
PointedEars
Nov 23 '05 #6

P: n/a
In article <MP************************@news.tiscali.fr>, je**@aposte.org
says...
Hi. How to do document.lastModified works with Netscape and Opera ? Or
what other way to take to simply display the last update date about
current page ?

OK, thanks all. Effectively, it works under NN and Opera too : it was
just a matter of DIV position which masked the white font on a white
background :-(
Nov 23 '05 #7

P: n/a
JRS: In article <MP************************@news.tiscali.fr>, dated
Tue, 15 Nov 2005 08:20:28, seen in news:comp.lang.javascript, JellyON
<je**@aposte.org> posted :
How to do document.lastModified works with Netscape and Opera ? Or
what other way to take to simply display the last update date about
current page ?

Be warned that some software gives lastModified as an FFF string with a
two-digit year, even when set for a non-FFF locality (FFF is used in US;
perhaps part of CA; and probably, alas, now Iraq).

If the string is numeric and displayed directly, the user may be able to
deduce which is year, which is month, and which is day; it can be done
reliably for 11/16/05, but not for 03/04/05.

IMHO, the best way is to type the date into the HTML when you modify the
page. That has the additional advantage of not changing if the page is
reloaded for any reason that does not affect the reader.
See below.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 23 '05 #8

P: n/a
Dr John Stockton wrote:
IMHO, the best way is to type the date into the HTML when you modify the
page. That has the additional advantage of not changing if the page is
reloaded for any reason that does not affect the reader.


For whatever it's worth, I've been doing the same thing for a copyright
line, and have had no practical problem with

year = new Date (document.lastModified).getFullYear ();

on Firefox, IE6, Opera, or Safari.

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
Nov 23 '05 #9

P: n/a
JRS: In article <2l*****************@fe09.lga>, dated Sun, 20 Nov 2005
20:24:06, seen in news:comp.lang.javascript, John W. Kennedy
<jw*****@attglobal.net> posted :
Dr John Stockton wrote:
IMHO, the best way is to type the date into the HTML when you modify the
page. That has the additional advantage of not changing if the page is
reloaded for any reason that does not affect the reader.


For whatever it's worth, I've been doing the same thing for a copyright
line, and have had no practical problem with

year = new Date (document.lastModified).getFullYear ();

on Firefox, IE6, Opera, or Safari.


It gives me 1905, for a page last changed on 2005-11-19, on which

new Date (document.lastModified) -> Sun Nov 19 23:14:10 UTC 1905

The string is 11/19/05 23:14:10 which is of course FFF and neither
ISO nor EU field order. However, even before the 13th of a month, new
Date(string) has a matching error.

Never assume that, just because American-originated software often works
correctly for Americans in America, that it works equally correctly, or
even consistently, otherwise.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 23 '05 #10

P: n/a
Dr John Stockton wrote:
JRS: In article <2l*****************@fe09.lga>, dated Sun, 20 Nov 2005
20:24:06, seen in news:comp.lang.javascript, John W. Kennedy
<jw*****@attglobal.net> posted :
Dr John Stockton wrote:
IMHO, the best way is to type the date into the HTML when you modify the
page. That has the additional advantage of not changing if the page is
reloaded for any reason that does not affect the reader.

For whatever it's worth, I've been doing the same thing for a copyright
line, and have had no practical problem with

year = new Date (document.lastModified).getFullYear ();

on Firefox, IE6, Opera, or Safari.


It gives me 1905, for a page last changed on 2005-11-19, on which

new Date (document.lastModified) -> Sun Nov 19 23:14:10 UTC 1905

The string is 11/19/05 23:14:10 which is of course FFF and neither
ISO nor EU field order. However, even before the 13th of a month, new
Date(string) has a matching error.

Never assume that, just because American-originated software often works
correctly for Americans in America, that it works equally correctly, or
even consistently, otherwise.


1) As far as I can tell, there is no format specified for lastModified.

2) But RFC 1123 is specified for HTTP last-modified.

3) My server correctly uses RFC 1123.

4) Every browser I have tested with my server puts RFC 1123 into
lastModified.

5) It would appear to be the case that most, very likely all, browsers
copy last-modified directly to lastModified.

6) I don't see how the above nonstandard string is getting into the
situation at all, unless you are working with a nonconformant server.

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
Nov 25 '05 #11

P: n/a
VK

Dr John Stockton wrote:
Never assume that, just because American-originated software often works
correctly for Americans in America, that it works equally correctly, or
even consistently, otherwise.


Eh?

As it was well explained to you, Last-Modified content header has a
well specified and internationally accepted format. A quick check
across domains would show it to you:
(using AjaxToolbox from <http://www.ajaxtoolbox.com>,
getResponseHeader, time is replaced for consistency)

http://www.merlyn.demon.co.uk/index.htm

Last-Modified: Wed, 16 Nov 2005 HH:MM:SS GMT
document.lastModified: 11/25/2005 HH:MM:SS

http://www.geocities.com/schools_ring/ArrayAndHash.html
Last-Modified: Fri, 25 Nov 2005 HH:MM:SS GMT
document.lastModified: 11/25/2005 HH:MM:SS

The content header is uniform trasport format, and
document.lastModified is set based on this header using your system
locale. You don't need to bother what format for Content-Header is used
as you don't need to bother how many bytes contained in TCP/IP packets
used do deliver this particular page.

That's really ...stupid to try to find a national issues in a
*transport format*. Yes, Internet (Arpanet) was originally made by
Americans and for Americans so you cannot blame on them that used their
standards and not say Chinese Lunar Calendar (no offense to China). But
as it was said, transport format is used only to deliver data to
client, so computer could use a known pattern to re-format it. Unless
you specially apply yourselve you will never see the original transport
form.

So concerning year 2005 which becomes year 1005 or so on "your"
computer: it's time to reinstall ;-)

Nov 25 '05 #12

P: n/a
In article <43********@nap.mtholyoke.edu>, John W. Kennedy
<jw*****@attglobal.net> writes

<snip>
2) But RFC 1123 is specified for HTTP last-modified.

<snip>

RFC 2068, which supersedes 1123, says that browsers MUST accept all
three of these date formats :

Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format

Notice the '94' horror.

John
--
John Harris
Nov 26 '05 #13

P: n/a
In article <11**********************@g14g2000cwa.googlegroups .com>, VK
<sc**********@yahoo.com> writes

<snip>
As it was well explained to you, Last-Modified content header has a
well specified and internationally accepted format.

<snip>

Well, well. Here's VK quoting a published standard, one where some of
the committee members are academics.

We never thought to see the day!

John
--
John Harris
Nov 26 '05 #14

P: n/a
JRS: In article <43********@nap.mtholyoke.edu>, dated Thu, 24 Nov 2005
16:23:43, seen in news:comp.lang.javascript, John W. Kennedy
<jw*****@attglobal.net> posted :
Dr John Stockton wrote:
JRS: In article <2l*****************@fe09.lga>, dated Sun, 20 Nov 2005
20:24:06, seen in news:comp.lang.javascript, John W. Kennedy
<jw*****@attglobal.net> posted :
Dr John Stockton wrote:
IMHO, the best way is to type the date into the HTML when you modify the
page. That has the additional advantage of not changing if the page is
reloaded for any reason that does not affect the reader.
For whatever it's worth, I've been doing the same thing for a copyright
line, and have had no practical problem with

year = new Date (document.lastModified).getFullYear ();

on Firefox, IE6, Opera, or Safari.
It gives me 1905, for a page last changed on 2005-11-19, on which

new Date (document.lastModified) -> Sun Nov 19 23:14:10 UTC 1905

The string is 11/19/05 23:14:10 which is of course FFF and neither
ISO nor EU field order. However, even before the 13th of a month, new
Date(string) has a matching error.

Never assume that, just because American-originated software often works
correctly for Americans in America, that it works equally correctly, or
even consistently, otherwise.


1) As far as I can tell, there is no format specified for lastModified.


Agreed.
2) But RFC 1123 is specified for HTTP last-modified.
Agreed.
3) My server correctly uses RFC 1123.
That seems very likely.
4) Every browser I have tested with my server puts RFC 1123 into
lastModified.
Then test more browsers. Or read the newsgroup FAQ.
5) It would appear to be the case that most, very likely all, browsers
copy last-modified directly to lastModified.
Perhaps; but not all.
6) I don't see how the above nonstandard string is getting into the
situation at all, unless you are working with a nonconformant server.


It is what the browser gives, both when reading from the server I use
for my pages (and AFAIR for all other servers) and when reading from the
local disc. "My" server is undoubtedly compliant.
BTW, the header line is, by RFC, in English; you seem to be American,
and so have a system configured for a form of English. It occurs to me
that in a system configured for non-English, javascript lastModified
*might* be localised and use non-English words.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 26 '05 #15

P: n/a
JRS: In article <11**********************@g14g2000cwa.googlegroups .com>
, dated Fri, 25 Nov 2005 02:57:51, seen in news:comp.lang.javascript, VK
<sc**********@yahoo.com> posted :

Dr John Stockton wrote:
Never assume that, just because American-originated software often works
correctly for Americans in America, that it works equally correctly, or
even consistently, otherwise.
Eh?

As it was well explained to you, Last-Modified content header has a
well specified and internationally accepted format. A quick check
across domains would show it to you:
(using AjaxToolbox from <http://www.ajaxtoolbox.com>,
getResponseHeader, time is replaced for consistency)


IRRELEVANT. I'm referring to javascript lastModified, not the header
string; the header string is specified by an RFC and I have no knowledge
of any servers giving a non-compliant form.

http://www.merlyn.demon.co.uk/index.htm

Last-Modified: Wed, 16 Nov 2005 HH:MM:SS GMT
Should be about that; approx. 18:42 GMT.
document.lastModified: 11/25/2005 HH:MM:SS
That's US format, and the wrong date. Your browser has not copied the
transport string.

http://www.geocities.com/schools_ring/ArrayAndHash.html
Last-Modified: Fri, 25 Nov 2005 HH:MM:SS GMT
document.lastModified: 11/25/2005 HH:MM:SS
Your browser has not copied the transport string.
The content header is uniform trasport format, and
document.lastModified is set based on this header using your system
locale.
It is set based on the value of the date in the header, agreed.

You don't need to bother what format for Content-Header is used
as you don't need to bother how many bytes contained in TCP/IP packets
used do deliver this particular page.

That's really ...stupid to try to find a national issues in a
*transport format*. Yes, Internet (Arpanet) was originally made by
Americans and for Americans so you cannot blame on them that used their
standards and not say Chinese Lunar Calendar (no offense to China). But
as it was said, transport format is used only to deliver data to
client, so computer could use a known pattern to re-format it. Unless
you specially apply yourselve you will never see the original transport
form.
But I was not referring to the transport form; that is satisfactory
although not wisely chosen (it should be ISO 8601, but the US ignores
that apart from making it (AIUI) a Federal standard).
So concerning year 2005 which becomes year 1005 or so on "your"
computer: it's time to reinstall ;-)


I assure you that it is my computer; I recall purchasing it with my own
money.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Nov 26 '05 #16

P: n/a
VK
John G Harris wrote:
Well, well. Here's VK quoting a published standard, one where some of
the committee members are academics.

We never thought to see the day!


<offtopic of document.lastModified>

You mean you've found in my postings a call to an anarchie? Nothing
more wrong than that - in standards I'm more a follower of a
distatorship. ;-)

As you may noticed already I'm a Nietzsche follower in this domain: "A
strong makes the rules - a weak has to follow them".
* where [this domain] means business and business standards
exclusively*

It's the end of the year 2005 and still many of so-called "browsers"
fail to pass the basic IQ test of ECMA 262 written at the end of 1999.
Do they need another 6 years to finish the primary school? Business is
not a schools for special children where the class doesn't advance
until the last in the class got the material. It's more of the Ivy
Leage - everyone has to rush to keep up with the leader.

JavaScript 1.5 / JScript 5.5 are standards in use for several years
already. Others have to support *at least* ECMA 262 so we could skip on
them gracefully. The most difficult mental cases (like Konqueror 1.x)
are out of any help which community could provide them.
<offtopic>

Nov 26 '05 #17

P: n/a
John G Harris wrote:
In article <43********@nap.mtholyoke.edu>, John W. Kennedy
<jw*****@attglobal.net> writes

<snip>
2) But RFC 1123 is specified for HTTP last-modified. <snip>

RFC 2068, which supersedes 1123,


No, RFC 2068 is a specification of HTTP 1.1 (obsoleted by RFC 2616), the
other is a date format.
says that browsers MUST accept all
three of these date formats :

Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format

Notice the '94' horror.


RFC 2068 and RFC 2616 both say that, although a browser must accept any
of those forms, a server must send only the RFC 1123 format.

In any case, I am concerned only with my own server, which /does/ send
the RFC 1123 format.

--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
Nov 27 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.