473,406 Members | 2,217 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,406 software developers and data experts.

mtime?

Hello,

does anybody know, if there is a possibility to get the date and time of the
last modification of a document (file) from withing JavaScript?

Regards,

Oliver

Dec 7 '06 #1
4 1709

Oliver Block wrote:
Hello,

does anybody know, if there is a possibility to get the date and time of the
last modification of a document (file) from withing JavaScript?
alert(document.lastModified);

There is an FAQ entry:

<URL: http://www.jibbering.com/faq/#FAQ4_30 >
<FAQENTRY>
The entry:

" 4.30 How do I format Last Modified date with javascript

Apparently, new Date() reads it correctly, though problems can occur
if the browser returns only two digits for the year. In particular,
time zone, field order and separators may vary. It is also reliant on
the server's clock having been correctly set at the time of upload. See
the URL below."

is cryptic and doesn't answer the question. The link appears to point
to the wrong reference, I need to scroll down several pages (6 "page
downs") to find the bit on lastModified. The use of a small, italic
font on a bright yellow background makes reading the page very
difficult. The text in the box with a green/blue background is nearly
illegible on my monitor (17" at 1280x1024, default font 16pt).

A suggested alternative wording is:

"The document.lastModified property can be formatted either by string
manipulation or by creating a Date object and using it to generate a
formatted string, e.g.

if (typeof document.lastModified == 'string') {
alert( new Date(document.lastModified) );
}

Further information can be found at: <insert current link>"

The styles and colours used in the linked page should be reviewed with
accessibility and legibility in mind.

--
Rob

Dec 7 '06 #2
RobG said the following on 12/6/2006 8:38 PM:
Oliver Block wrote:
>Hello,

does anybody know, if there is a possibility to get the date and time of the
last modification of a document (file) from withing JavaScript?

alert(document.lastModified);

There is an FAQ entry:

<URL: http://www.jibbering.com/faq/#FAQ4_30 >
<FAQENTRY>
The entry:

" 4.30 How do I format Last Modified date with javascript

Apparently, new Date() reads it correctly, though problems can occur
if the browser returns only two digits for the year. In particular,
time zone, field order and separators may vary. It is also reliant on
the server's clock having been correctly set at the time of upload. See
the URL below."

is cryptic and doesn't answer the question.
It doesn't even come close. And, the Subject is too specific as it
limits itself to the Last Modified when you format Last Modified the
same way you would format any other Date.
The link appears to point to the wrong reference,
I think the best reference, for an FAQ and a newbie reading the FAQ,
doesn't exist in that page.
I need to scroll down several pages (6 "page downs") to find the
bit on lastModified. The use of a small, italic font on a bright yellow
background makes reading the page very difficult.
Indeed it does.
The text in the box with a green/blue background is nearly
illegible on my monitor (17" at 1280x1024, default font 16pt).
A suggested alternative wording is:

"The document.lastModified property can be formatted either by string
manipulation or by creating a Date object and using it to generate a
formatted string, e.g.

if (typeof document.lastModified == 'string') {
alert( new Date(document.lastModified) );
}

Further information can be found at: <insert current link>"
<URL: http://www.javascripttoolbox.com/lib/date/>
<g>
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 7 '06 #3

Randy Webb wrote:
RobG said the following on 12/6/2006 8:38 PM:
[...]
Further information can be found at: ...

<URL: http://www.javascripttoolbox.com/lib/date/>
<g>
I'm not a fan of suggesting any particular library unless it stands out
as a paragon or seminal work, but what the heck... :-)
--
Rob

Dec 7 '06 #4
In comp.lang.javascript message
<11*********************@16g2000cwy.googlegroups.c om>, Wed, 6 Dec 2006
17:38:22, RobG <rg***@iinet.net.auwrote:
>
Oliver Block wrote:
>does anybody know, if there is a possibility to get the date and time of the
last modification of a document (file) from withing JavaScript?
Note : the question does not definitely assert that the document whose
date is wanted is the document running the javascript. I could want my
Index page to show the dates of all the pages that it points to. AFAIK,
javascript in a Web page cannot obtain the date of any other page,
except by loading the other page into a window and addressing its
lastModified [1]. But Javascript in WSH should be able to get such
stuff directly, for local files.

[1] testing in WinXP sp2 IE6 js-quick.htm,
Q = window.open("js-alarm.htm", "fred")
Q.document.lastModified
shows 11/26/2006 18:14:28 - FFF, no GMT, else OK.

alert(document.lastModified);
In some browsers and countries, that will show a wrong, but plausible,
date for 11 days out of every month, and a ludicrous one for every other
day but one. In some browsers, the century has been undefined. I've
only heard of one case where the lastModified date string includes an
indication of the offset from GMT.

>There is an FAQ entry:

<URL: http://www.jibbering.com/faq/#FAQ4_30 >
<FAQENTRY>
The entry:

" 4.30 How do I format Last Modified date with javascript
There "format" is not interpreted with the appropriate emphasis; the
section was not intended to refer to the presentation of the Date Object
as a string, but to the correct interpretation of lastModified itself.

Change "format" to "handle".

Apparently, new Date() reads it correctly, though problems can occur
if the browser returns only two digits for the year. In particular,
time zone, field order and separators may vary. It is also reliant on
the server's clock having been correctly set at the time of upload. See
the URL below."

is cryptic and doesn't answer the question. The link appears to point
to the wrong reference, I need to scroll down several pages (6 "page
downs") to find the bit on lastModified.
It points to the <H2heading "Last Modified", where the topic begins;
that is as intended.

The use of a small, italic
font on a bright yellow background makes reading the page very
difficult. The text in the box with a green/blue background is nearly
illegible on my monitor (17" at 1280x1024, default font 16pt).
ISTM that the font size there is about what the newFAQ gives me, but the
face is more legible for me (it will be "monospace"). Black-on-yellow
is agreed to give a clear distinction by most ordinary UK wasps.
Monitors vary; here I see it as a full, but not bright, yellow, and in
the Library ISTR it as being rather paler. It is the colour called
"yellow"; #FF0000.

>A suggested alternative wording is:

"The document.lastModified property can be formatted either by string
manipulation or by creating a Date object and using it to generate a
formatted string, e.g.

if (typeof document.lastModified == 'string') {
alert( new Date(document.lastModified) );
}
Are there any systems where lastModified exists and is not a String? If
not, maybe if (!document.lastModified) ? Are there any systems where
it does not exist?

My belief is that, apart from the missing GMT offset and possible
century error, all browsers will, using your code, get the right year,
month, and day; perhaps all recent ones will get the right century.

The century question is trivial to handle; all pages are read (if at
all) after they've been written, and few authors yet expect their pages
to be in use after 2099. But showing "Last update : 1906" or "Last
update : Fri 07 Dec 06" is unprofessional.

The data is transmitted in required explicit GMT (from my servers, and
from all compliant ones) but I don't know how to tell, in javascript,
whether the date in lastModified is copied as GMT or converted to local.

ECMA could, for the future, usefully add document.lastModMSec as if
obtained by +new Date(<Last-Modified RFC2616 Header>). It would be
unambiguous and would load efficiently into a Date Object. Or, of
course, add document.lastModObj, a Date Object.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
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.
Dec 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Ishwar Rattan | last post by:
Say a filea.py contains a number of functions defined in it (using def afn(): etc.) in pyhton, filea is imported to use afn (filea.afn() etc.), it cerates a filea.pyc file, what is the purpose...
9
by: Peter Hansen | last post by:
The term "mock filesystem" refers to code allowing unit or acceptance tests to create, read and write, and manipulate in other ways "virtual" files, without any actual disk access. Everything is...
5
by: Erwin Kloibhofer | last post by:
what if i have a webpage that displays the text "please wait, this may take a few seconds..." and it now waits until some event on the server happens. whatever this is, this can be quick, but it...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
5
by: Peter Erickson | last post by:
I am running postgresql 7.4.2 and having problems creating a trigger function properly. I keep getting the following error: ERROR: OLD used in query that is not in rule I have a table called...
5
by: Skip | last post by:
Hello, I am reposting this from another group, because I had no responses. I need to get the max row date from the following query. There is a date field in rcompl.date_time. There can be...
6
by: nicy12 | last post by:
Hi! my name is Peter. iam working on the php platform. while trying to run and compile a program i get the undefined offset error iam nto much familiar with this error . Please help me . Thanks in...
9
by: Wolfgang Draxinger | last post by:
H folks, I got, hmm not really a problem, more a question of elegance: In a current project I have to read in some files in a given directory in chronological order, so that I can concatenate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.