<script> var dob = new Date("12/11/2012"); //calculate month difference from current date in time var month_diff = Date.now() - dob.getTime(); //convert the calculated difference in date format var age_dt = new Date(month_diff); //extract year from date var year = age_dt.getUTCFullYear(); //now calculate the age of the user var age = Math.abs(year - 1970); //display the calculated age document.write("Age of the date entered: " + age + " years"); </script>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter