CoffeeQuick
Programmer
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
Any suggestions would be appreciated.
Thanks in advance,
John
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