<!DOCTYPE html>charset="utf-8"W3Cschool教程(w3cschool.cn)id="demo"单击按钮计算从1970年1月到现在有多少年?onclick="myFunction()"点我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;}