Skip to content

Instantly share code, notes, and snippets.

@jacobbednarz
Created March 25, 2012 15:03
Show Gist options
  • Save jacobbednarz/2196919 to your computer and use it in GitHub Desktop.
Save jacobbednarz/2196919 to your computer and use it in GitHub Desktop.
Dynamically update age
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
</head>
<body>
<p>My age is: <span id="age"></span></p>
</body>
<script>
var age_span = document.getElementById('age');
var dob = 1991;
var current_year = new Date().getFullYear();
age_span.innerHTML = current_year - dob;
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment