Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking age problem with date format

Status
Not open for further replies.

CoffeeQuick

Programmer
Jul 6, 2004
23
0
0
GB
Hi,

I have been asked to produce an on-line application form, which requires a date of birth to be entered and then checked.

But I hit a problem with the date format, as the site is for the uk, the date format is dd/mm/yyyy, but the system date is represented in javascript in the usa format mm/dd/yyyy.

I have writen a script to re-arrange the uk date to match the usa format before doing the age check.

But I am wondering if the is a better way to do this, or a way that does not need me to re-format the date.

Here is my code to re-format the date entered
Code:
function changeToUsaDate(ukdate) {
  
     var elems = ukdate.split("/");

       var day = elems[0];
       var month = elems[1];
       var year = elems[2];
       usadate = month + "/" + day + "/" + year;

       return usadate;
}

Any suggestions would be appreciated.

Thanks in advance,

John
 
Pick from a calendar, don't have a javascript example here right now but I'm sure there are several out there.



Greetings, Harm Meijer
 
Absolutely. That is really the only way to avoid date format confusion (apart from brainwashing users... and it's cheaper to get a calendar solution in, I'd say ;o)

Dan

[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top