ArchiveApril 2015

JQuery – Calculate age from DOB

J

So a user has entered their date of birth in a text box and you want to calculate their age, and take in to account leap years. Create a JQuery function (this code): function calculateAge(dob) { var now = new Date(); function isLeap(year) { return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); } var days = Math.floor((now.getTime() – dob.getTime())/1000/60/60/24); var age =...

Archive

Tags

Get in touch

I'm available on just about every social media platform out there as RMTWeb.