Created
January 4, 2017 20:30
-
-
Save aazbeltran/66af5c0f4022a0576741c76bd4d5eeaa to your computer and use it in GitHub Desktop.
Calcular edad para David
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fechaNacimiento = new Date("1995-06-02"); | |
function edad(fechaNacimiento) { | |
var diff = Math.floor(new Date().getTime() - fechaNacimiento.getTime()); | |
var dia = 1000 * 60 * 60 * 24; | |
var dias = Math.floor(diff / dia); | |
var meses = Math.floor(dias / 31); | |
var anio = Math.floor(meses / 12); | |
return anio; | |
} | |
edad(fechaNacimiento); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment