欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript動(dòng)態(tài)獲取登錄時(shí)間和在線時(shí)長

 更新時(shí)間:2016年02月25日 15:03:05   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了javascript動(dòng)態(tài)獲取登錄時(shí)間和在線時(shí)長的相關(guān)資料,獲得登錄時(shí)候的時(shí)間,用來和動(dòng)態(tài)的時(shí)間做差來求時(shí)長,感興趣的小伙伴們可以參考一下

本文實(shí)例介紹了javascript動(dòng)態(tài)獲取登錄時(shí)間和在線時(shí)長的相應(yīng)代碼,分享給大家供大家參考,具體內(nèi)容如下

效果圖:

實(shí)現(xiàn)代碼:

<html>
 <head>
 <title>online</title>
 <script language=javaScript>
 ///這里是獲得登錄時(shí)候的時(shí)間,用來和動(dòng)態(tài)的時(shí)間做差來求時(shí)長
 var s = new Date();

 function clockon() {
 var thistime = new Date();
 //時(shí)間差
 diff = new Date();
 diff.setTime(Math.abs(thistime.getTime() - s.getTime()));
 timediff = diff.getTime();
 hos = Math.floor(timediff / (1000 * 60 * 60));
 mins = Math.floor(timediff / (1000 * 60));
 secs = Math.floor(timediff / 1000);
 //end
 var hours = thistime.getHours();
 var minutes = thistime.getMinutes();
 var seconds = thistime.getSeconds();

 if (eval(hours) < 10) {
  hours = "0" + hours;
 }
 if (eval(minutes) < 10) {
  minutes = "0" + minutes;
 }
 if (seconds < 10) {
  seconds = "0" + seconds;
 }
 thistime = hours + ":" + minutes + ":" + seconds;
 bgclockshade.innerHTML = thistime//這里動(dòng)態(tài)的嵌入當(dāng)前的時(shí)間
 //如果不取余的話,秒數(shù)是一直上升的,所以在達(dá)到一個(gè)60的時(shí)候就取余就可以解決這個(gè)問題了
 if (secs > 59) {
  secs = secs % 60;
 }
 if (mins > 59) {
  mins = mins % 60;
 }
 if (eval(secs) < 10) {
  secs = "0" + secs;
 }
 if (eval(mins) < 10) {
  mins = "0" + mins;
 }
 if (eval(hos) < 10) {
  hos = "0" + hos;
 }
 jishi.innerHTML = hos + ":" + mins + ":" + secs;
 var timer = setTimeout("clockon()", 200);
 }
</script>
 </head>
 <body onload="clockon();">
 登錄時(shí)間:
 <div id="bgclockshade"></div>
 上網(wǎng)時(shí)長:
 <div id="jishi"></div>
 </body>
</html>

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評(píng)論