Skip to content

Instantly share code, notes, and snippets.

@bih
Last active June 24, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bih/62f4b847b5ec100f61677eaa22c9f82c to your computer and use it in GitHub Desktop.
Save bih/62f4b847b5ec100f61677eaa22c9f82c to your computer and use it in GitHub Desktop.
Calculate Your Age
(function(date_of_birth, decimal_points){
var date_today = Date.now()
, date_born = Date.parse(date_of_birth)
, difference = date_today - date_born;
var divided_to_seconds = difference / 1000
, divided_to_minutes = divided_to_seconds / 60
, divided_to_hours = divided_to_minutes / 60
, divided_to_days = divided_to_hours / 24
, divided_to_years = divided_to_days / 365;
var decimal_divisor = 10 ** decimal_points;
return parseInt(divided_to_years * decimal_divisor) / decimal_divisor;
})('1993-01-01', 10);
d='1993-01-01',l=10;parseInt((Date.now()-Date.parse(d))/31536000000*(10**l))/(10**l)
d=Date;((d.now()-d.parse('1993-01-01'))/31536000000).toFixed(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment