JRS: In article <
[email protected]>,
dated Wed, 1 Sep 2004 12:40:27, seen in Abby
Lee said:
http://www.apriori-it.co.uk/FormatDate.asp
I found the above date format script while doing a search.
it works fine except with the format mm/dd/yyyy.
Type in 01/02/03 and hit the "format date" link...the month and day
will switch back and forth. This does not happen if you use the
dd/mm/yyyy format. I want to use the mm/dd/yyyy part of this...can
someone tell me where the problem is?
I've looked at the script. It is of low quality, and the HTML is not
good either. The author clearly knows little of the subject, or is paid
by the yard. If you want bloatware that gives US formats, properly
tested, there are other sources.
It accepts days & months with many leading zeroes, and keeps them. It
does not extend years to 4 digits. Year 33 becomes 2033, but year 033
remains. Year 0000 is not Leap.
Each month can have the appropriate number of days 1..n , or 365/366 +
1..n, or 730/731 + 1..n (roughly stated).
It windows 2-digit years, but not 1-digit ones, into 1941..2040. It
accepts "Janitor" and "Octopus" as month-names.
It does toggle as described; while it can output UK & US forms, it reads
as UK if possible. Of course, most of us expect the reverse fault <G>.
To generate mm/dd/yyyy efficiently from a date object, if you must, see
below and adapt, say,
function LZ(x) { return (x<0||x>=10?"":"0") + x }
Date.prototype.ISOlocaldateStr =
new Function(" /* Date.ISOlocaldateStr */ with (this)\n return " +
"getFullYear()+'-'+LZ(getMonth()+1)+'-'+LZ(getDate())")
If you have a numeric date string in another format, rearrange it with a
RegExp .replace .