Time Lived v1.0

Discover your personal timeline. This fun script uses JavaScript to calculate exactly how many years and days a person has lived, presenting the results in a personalized alert box.

Life Experience Calculator

Copy the Script

<script>
function calculateLife() {
  var bDay = document.getElementById('bDay').value;
  var bMonth = document.getElementById('bMonth').value - 1;
  var bYear = document.getElementById('bYear').value;
  
  var today = new Date();
  var birth = new Date(bYear, bMonth, bDay);
  
  var diff = today.getTime() - birth.getTime();
  var days = Math.floor(diff / (1000 * 60 * 60 * 24));
  var years = Math.floor(days / 365.25);
  
  alert("You have lived for approximately " + days + " days, which is about " + years + " years!");
}
</script>