473,387 Members | 1,588 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.

document.lastModified

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

Similar topics

1
by: John Norvell | last post by:
I just noticed that recently the javascript I was using to format and display the last modified date of my web page is always reporting the current date instead. It used to work fine. This is true...
12
by: Bart | last post by:
Hallo, I'm have a problem with the following script: function wr(s) { //Just got tired of writing document.write, //so I created a shorthand version document.write(s);
12
by: *.* | last post by:
Hey- I seem to be having a problem with the document.lastModified property. The way it is suppose to work is that it returns the date and time at which the document was last modified. IN my...
2
by: Kam Bansal | last post by:
Hi all, We're using Apache 1.3 (I know, I know, there's a newer version...) and it seems that the document.lastModified does not return the correct date. On Netscape it shows 01/01/1970 and on...
15
by: Cerebral Believer | last post by:
Hi all, I am a newbie to JavaScript and am just trying to get a script going that will write the ful date and time to each webpage as it is viewed. Can anyone point out what mistakes there are...
2
by: dbahlmann | last post by:
Hi, I'm using document.lastModified function to return my document last mod date. The function returns 1-Jan-1970. The problem seems to be that the file name is index.php instead of index.html....
6
by: Kindler Chase | last post by:
I'm trying to iterate through a set of nodes and then edit/delete specific attributes using XPathNodeIterator. Adding attributes is no problem. My first question is how do I delete an attribute...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.