<html>
<body>
<p id="demo">Click the button to calculate the number of years since midnight, January 1, 1970.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var minutes=1000*60;
var hours=minutes*60;
var days=hours*24;
var years=days*365;
var d=new Date();
var t=d.getTime();
var y=Math.round(t/years);
var x = document.getElementById("demo");
x.innerHTML=y;
}
</script>
</body>
</html>