• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

用JavsScript实现网站运营时间代码

WordPress lixian 5年前 (2019-10-05) 1477次浏览 1个评论 扫描二维码
文章目录[隐藏]

前言

在建博客的时候,网站最底部放入一个网站运行时间统计绝对很有逼格,本网站使用的JavsScript代码有比较好的兼容性,特此分享。

核心代码

// JavaScript Document
function show_date_time(){
window.setTimeout("show_date_time()", 1000);
BirthDay=new Date("02-25-2019"); 
today=new Date();
timeold=(today.getTime()-BirthDay.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(daysold-e_daysold)*-24;
hrsold=Math.floor(e_hrsold);
e_minsold=(hrsold-e_hrsold)*-60;
minsold=Math.floor((hrsold-e_hrsold)*-60);
seconds=Math.floor((minsold-e_minsold)*-60);
span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;
}
show_date_time();

把上面JavsScript代码放入网站最底部

效果

用JavsScript实现网站运营时间代码


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:用JavsScript实现网站运营时间代码
喜欢 (10)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽
  1. Reading your article has greatly helped me, and I agree with you. But I still have some questions. Can you help me? I will pay attention to your answer. thank you.