Unexpected behavior of "lastModified"

K

Konrad Den Ende

I went:
document.write (document.lastModified);
to my document and everything was as expected as long as the
file was on the HDD and being tested. Then i uploaded it and,
to my biggest surprise, it looks like the date/time given refere
to the download time (as in update/reload time). I can imagine
it has to do with the fact that the actual file gets downloaded
to a users HDD (hence being created then).

So, am i right about the above? How do i solve the issue (that is
how do i get the date of when a document was edited)?

--

Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------
 
R

Richard Cornford

Konrad Den Ende wrote:
So, am i right about the above? How do i solve the issue (that is
how do i get the date of when a document was edited)?

When a browser receives a response from a server it uses the -
Last-Modified - HTTP header (see RFC 2616 - Hypertext Transfer
Protocol -- HTTP/1.1) sent with it to determine the -
document.lastModified - value. If no - Last-Modified - header is sent
the browser usually defaults to using the current date and time. Local
file system access uses different rules and it can get the lastModified
date from the OS directly.

It sounds like your server is not configured to send - Last-Modified -
HTTP headers.

Richard.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
I went:
document.write (document.lastModified);
to my document and everything was as expected as long as the
file was on the HDD and being tested. Then i uploaded it and,
to my biggest surprise, it looks like the date/time given refere
to the download time (as in update/reload time). I can imagine
it has to do with the fact that the actual file gets downloaded
to a users HDD (hence being created then).

So, am i right about the above? How do i solve the issue (that is
how do i get the date of when a document was edited)?

The best way is to type in the date when you edit it, either in GMT or
in Swedish time. You can do that in a format which is everywhere
unambiguous. You need not change it if the editing is purely cosmetic.

Normally, the Last-Modified header returns the date/time when the file
was placed on the server, in GMT; and the lastModified string represents
this in a browser-dependent manner. If you see otherwise, discuss with
your server's operators. It may be that the header is missing and the
browser substitutes the present time (both are inexcusable).

Note that the lastModified string, in at least one browser, in at least
one localisation, presents the date in a deceptive form.

Care is needed, and not taken by http://www.unicode.org/charts/
which shows me "Last updated: - 10/21/1903 00:57:16". It's impressive
that Unicode was prepared over a century ago, and amazing if years then
had at least 21 months. If they had not tried to improve the string, it
would not have shown me the wrong century - admittedly, not the right
one either.

See below.
 
K

Konrad Den Ende

It sounds like your server is not configured to
send - Last-Modified - HTTP headers.

Sp what you're saying is that i have to live with it or change
the web hotel? Thatäs cold...

--

Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top