<script>
//页面加载完执行下方函数
share_data_time();
function share_data_time() {
//每秒执行一次
window.setTimeout("share_data_time()", 1000);
//网站建立时间
BirthDay = new Date("5/11/2018 00:00:00");
//获取当前时间
today = new Date();
//总豪秒数
timeold = (today.getTime() - BirthDay.getTime());
//总秒数
secondsold = Math.floor(timeold / 1000);
e_daysold = timeold / (24 * 60 * 60 * 1000);
//相差天数
daysold = Math.floor(e_daysold);
e_hrsold = (e_daysold - daysold) * 24;
//相差小时数
hrsold = Math.floor(e_hrsold);
e_minsold = (e_hrsold - hrsold) * 60;
//相差分钟数
minsold= Math.floor(e_minsold);
//相差秒数
seconds = Math.floor((e_minsold - minsold) * 60);
//将所获取的时间拼接到一起,再把值显示到页面
share_time.innerHTML = "已共享:" + daysold + "天" + hrsold + "小时" + minsold + "分" + seconds + "秒";
}
</script>