date validation scrip

A

Abby Lee

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?
 
D

Dr John Stockton

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?


Having an off-line news reader, I rarely follow Web references while
answering incomplete News questions. Your "switch back and forth" is
most unclear.

Date format mm/dd/yyyy is really stupid; 99% of countries, and parts of
Canada, laugh sneer or weep at seeing it. You should follow the
International standard, ISO 8601, which is AIUI also a US Federal
standard; yyyy-mm-dd is correct and unambiguous; and yyyy-mm-dd is
reliable.

Evidence suggests that even Americans can understand a yyyy/mm/dd date
when they see it.

Read the newsgroup FAQ; see below.
 
D

Dr John Stockton

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 .
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top