Posts by Henrick Mello • 11 points
1 post
-
1
votes6
answers5628
viewsA: Calculate age in years using javascript
function idade(d1, d2) { d2 = d2 || new Date(); var diff = d2.getTime() - d1.getTime(); return Math.floor(diff / (1000 * 60 * 60 * 24 * 365.25)); } console.log(idade(new Date(1998, 09, 3)));…