We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

nicolaspar on 04/18/08


Tagged

javascript data AGE calculate birthdate


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

blackabee


getAge


Published in: JavaScript 


  1. //Function return age.
  2. function getAge(Y,M,D){
  3. var now=new Date(),m=now.getMonth()+1,d=now.getDate();
  4. return now.getFullYear()-Y+(M>m?-1:M==m&&D>d?-1:0);
  5. }

Report this snippet 

You need to login to post a comment.