JRS: In article <hU*****************@fe3.news.blueyonder.co.uk>, dated
Wed, 26 Jul 2006 10:57:17 remote, seen in news:comp.lang.javascript, A
Browne <cl**@spam.fritter.glasgowrowingclub.orgposted :
>if (Date.parse(document.lastModified) 0) {
var last = new Date(document.lastModified);
document.write(last.toLocaleString());
}
That code does not write in IE4 - but maybe that's correct. Executing
in local master of <URL:http://www.merlyn.demon.co.uk/js-quick.htm>,
document.lastModified 07/24/06 16:48:28 FFF & Y2k, otherwise OK
Date.parse(document.lastModified) -2002003892000
06 is interpreted as 1906, before Epoch, hence negative answer; hence
rest ignored. The code does what it should do for me.
It's silly to throw away the Date.parse result, since it is an ideal
argument for new Date - why do string-to-number conversion twice?
OTOH you could drop the Date.parse and use new Date() there ;
if ((D = new Date(document.lastModified))>1e12)
document.write(D.toLocaleString());
which works for me apart from the Y2k error and the misfortune that
toLocaleString() incorrectly gives me an FFF date.
The 1e12 corresponds to 2001-09-09 01:46:40 UTC; it seems safe to assume
that any page you code in future will be coded after that.
Check, as I did, your code piece by piece, starting with the
lastModified string itself.
Read the newsgroup FAQ. Then re-read 4.30 & follow link.
--
© 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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.