LordMerlin
01-19-2006, 11:12 AM
Hi everyone.
I'm trying to incorporate a date of birth to age calculator on my site. Currently I have the following Date Validation Script (http://www.smartwebby.com/DHTML/date_validation2.asp) which validates the date of birth to make sure it's in the dd/mm/yyyy format.
Then, I have the following piece of code, which calculates the age, according to the date of birth
<script language="javascript" type="text/javascript">
<!--
function calc(form) {
var today= new Date();
var birthday= new Date(document.form1.dob.value);
secold=(today.getYear()-birthday.getYear())*31557600+(today.getMonth()-birthday.getMonth())*2629800+(today.getDay()-birthday.getDay())*86400+today.getHours()*3600+today.getMinutes()*60+today.getSeconds()
document.form1.age.value=Math.floor(((secold/3600)/24)/365.25);
}
//-->
</script>
My problem is, this age calculator expects the date format to be mm/dd/yyyy. Is there a way of specifying that my date in the the format of dd/mm/yyyy?
I'm trying to incorporate a date of birth to age calculator on my site. Currently I have the following Date Validation Script (http://www.smartwebby.com/DHTML/date_validation2.asp) which validates the date of birth to make sure it's in the dd/mm/yyyy format.
Then, I have the following piece of code, which calculates the age, according to the date of birth
<script language="javascript" type="text/javascript">
<!--
function calc(form) {
var today= new Date();
var birthday= new Date(document.form1.dob.value);
secold=(today.getYear()-birthday.getYear())*31557600+(today.getMonth()-birthday.getMonth())*2629800+(today.getDay()-birthday.getDay())*86400+today.getHours()*3600+today.getMinutes()*60+today.getSeconds()
document.form1.age.value=Math.floor(((secold/3600)/24)/365.25);
}
//-->
</script>
My problem is, this age calculator expects the date format to be mm/dd/yyyy. Is there a way of specifying that my date in the the format of dd/mm/yyyy?