Hello Friends, It’s being long time I’ve not shared anything with you but today I am going to share a code for Creating Age Calculator in Javascript.
1 2 3 4 5 6 7 8 |
<script> function calculateAge(dob){ var dob = new Date(dob); var diffInMillis = Date.now() - dob.getTime(); var age = new Date(diffInMillis); // miliseconds from epoch return Math.abs(age.getFullYear() - 1970); } </script> |
Output
Thanks
Please share if you like
Comments