• 不断学习才有回报,学无止境!

添加网站运行时间

javascript技巧 箭翎 21次浏览 0个评论 扫描二维码

方法一:

<a>感谢您的支持与信任!本博客已正常经运行</a><a id="days"></a>0<a>天</a>
<script>
var s1 = '2013-07-01';//设置为你的建站时间
s1 = new Date(s1.replace(/-/g, "/"));
s2 = new Date();
var days = s2.getTime() - s1.getTime();
var number_of_days = parseInt(days / (1000 * 60 * 60 * 24));
document.getElementById('days').innerHTML = number_of_days;
</script>

方法二:

本博客已安全运行了:<span class="smalltxt">
<script>// <![CDATA[
BirthDay=new Date("07 01,2013");//设置为你的建站时间
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);
document.write("<font color=red>"+daysold+"</font>天 !");
// ]]></script>
</span>

方法三:

<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
<script>// <![CDATA[ var now = new Date(); function createtime(){ var grt= new Date("11/25/2013 21:51:00");//此处修改你的建站时间或者网站上线时间 now.setTime(now.getTime()+250); days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} document.getElementById("timeDate").innerHTML = "本站已安全运行"+dnum+"天"; document.getElementById("times").innerHTML = hnum + "小时" + mnum + "分" + snum + "秒"; } setInterval("createtime()",250); // ]]></script>

箭翎 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明添加网站运行时间
喜欢 (0)

Warning: copy(D:\phpstudy_pro\WWW\blog/avatar/.png) [function.copy]: failed to open stream: No such file or directory in D:\phpstudy_pro\WWW\blog\wp-content\themes\Record2.0\functions.php on line 495

Warning: filesize() [function.filesize]: stat failed for D:\phpstudy_pro\WWW\blog/avatar/.png in D:\phpstudy_pro\WWW\blog\wp-content\themes\Record2.0\functions.php on line 499

Warning: copy(D:\phpstudy_pro\WWW\blog/avatar/.png) [function.copy]: failed to open stream: No such file or directory in D:\phpstudy_pro\WWW\blog\wp-content\themes\Record2.0\functions.php on line 499
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址