JRS: In article <f%tqd.889$I52.36815@news.optus.net.au>, dated Mon, 29
Nov 2004 00:24:43, seen in news:comp.lang.javascript, RobG
<rgqld@iinet.net.auau> posted :
> function LZ(x) { return (x<0||x>=10?"":"0") + x }
> </script>
>
> You may want not want to add leading zeros to single digit months and
> days - it isn't necessary for ISO 8601 compliance but some think it
> looks better.
<BIG><BIG><BIG> HO YES IT IS NECESSARY </BIG></BIG></BIG>
ISO8601:2000(E) 5.2.1 is clear; and probably so for other values of E.
The year, except by agreement, should also be four digits (more after
9999).
In Y-D dates, D must be 3 digits.
Unless field lengths are constant, and separators do not fluctuate, the
full advantages of 8601 do not accrue - fixed-length dates can be sorted
as strings, fields can be extracted by position, ...
I predict an update, ISO8601:9???, making 5-digit years mandatory.

Signature
© 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.
RobG - 29 Nov 2004 22:49 GMT
[...]
> <BIG><BIG><BIG> HO YES IT IS NECESSARY </BIG></BIG></BIG>
>
> ISO8601:2000(E) 5.2.1 is clear; and probably so for other values of E.
Yes, quite correct. I can't think where I go the idea from. I've been
working extensively with metadata standards and absolutely should have
known - I can only think some brain-bits got flipped the wrong way.
[...]
> I predict an update, ISO8601:9???, making 5-digit years mandatory.
>
And you owe me a beer if it hasn't happened by 9999-12-31.

Signature
Rob
> You are depending upon the browser's default date format to fit your
> script - not a good idea, particularly when you can access the parts of
> the date directly and hence, reliably.
>
> Try this:
[snip]
Thanks a lot: your solution works fine in both browsers.
François