Skip to content

Instantly share code, notes, and snippets.

@mrl22
Created March 28, 2017 18:31
Show Gist options
  • Select an option

  • Save mrl22/99d3a4a1302ab2e5c8123bd4bf6c9b39 to your computer and use it in GitHub Desktop.

Select an option

Save mrl22/99d3a4a1302ab2e5c8123bd4bf6c9b39 to your computer and use it in GitHub Desktop.
My Age
<div id="age"></div>
var start = new Date('12/20/1984 03:07 AM');
var timer;
function age() {
var now = new Date();
var age = now.getTime()-start.getTime();
var year = (age / 31558859800);
document.getElementById('age').innerHTML = year.toFixed(10);
}
timer = setInterval(age, 30);
@import url('https://fonts.googleapis.com/css?family=Inconsolata');
#age {
width: 750px;
height: 200px;
text-align: center;
font-size: 96px;
font-family: 'Inconsolata', monospace;
position:absolute; /*it can be fixed too*/
left:0; right:0;
top:0; bottom:0;
margin:auto;
/*this to solve "the content will not be cut when the window is smaller than the content": */
max-width:100%;
max-height:100%;
overflow:auto;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment