Skip to content

Instantly share code, notes, and snippets.

@tomykaira
Last active January 4, 2019 14:25
Show Gist options
  • Select an option

  • Save tomykaira/783f6974bf7cba838aef759886c28862 to your computer and use it in GitHub Desktop.

Select an option

Save tomykaira/783f6974bf7cba838aef759886c28862 to your computer and use it in GitHub Desktop.
ar birthdate = new Date(1970, 1, 1);
var today = new Date();
var dayMs = 1000*60*60*24;
var startAge = 10;
var startPoint = new Date(birthdate.getTime());
startPoint.setYear(birthdate.getFullYear() + startAge);
var accum = startPoint.getTime();
for (var i = startAge; i < 100; i ++) {
accum += dayMs*365*i / startAge;
console.log(i, new Date(accum), (today.getTime() - accum) / dayMs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment