主頁 > 知識(shí)庫 > JSP獲取服務(wù)器時(shí)間以倒計(jì)時(shí)的形式在頁面顯示

JSP獲取服務(wù)器時(shí)間以倒計(jì)時(shí)的形式在頁面顯示

熱門標(biāo)簽:山東ai外呼電銷機(jī)器人好用嗎 汝南縣地圖標(biāo)注app 四川正規(guī)外呼系統(tǒng)軟件 甘肅銷售電銷機(jī)器人公司 智能電話機(jī)器人銷售話術(shù) 湖北地圖標(biāo)注公司 外呼直播語音系統(tǒng) 福建電銷貓機(jī)器人收費(fèi) 地圖標(biāo)注專業(yè)和非專業(yè)
復(fù)制代碼 代碼如下:

%@ page language="java" import="java.util.*"%>
!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
html xmlns="http://www.w3.org/1999/xhtml">
head>
%@ include file="/commons/meta.jsp"%>
%@ include file="/commons/meta-et.jsp"%>
%
Calendar cal = Calendar.getInstance();
int hour = cal.get(cal.HOUR_OF_DAY);
int minute = cal.get(cal.MINUTE);
int month = cal.get(cal.MONTH);
int date = cal.get(cal.DATE);
int year = cal.get(cal.YEAR);
int second = cal.get(cal.SECOND);
%>
script type="text/javascript" defer="defer">
var NowHour = "";//Today.getHours();
var NowMinute = "";//Today.getMinutes();
var NowMonth = "";//Today.getMonth();
var NowDate = "";//Today.getDate();
var NowYear = "";//Today.getYear();
var NowSecond = "";//Today.getSeconds();
//獲取服務(wù)端時(shí)間
function getTime(){
NowHour = %=hour%>;
NowMinute = %=minute%>;
NowMonth = %=month%>;
//NowMonth = (parseInt(NowMonth)+1);
NowDate = %=date%>;
NowYear = %=year%>;
NowSecond = %=second%>;
}
getTime();
startclock();
var timerID = null;
var timerRunning = false;
function showtime() {

var time='${enddate}';//獲取數(shù)據(jù)庫中結(jié)束時(shí)間或開始時(shí)間,然后開始計(jì)算離開始或結(jié)束還差多少時(shí)間
NowSecond = (parseInt(NowSecond)+1);
//-------------------------------------------------------------------
var a, a1, a2;
var EndTime ;
a = unescape('${enddate}').split(" "); //這是注釋,此句是倒計(jì)時(shí)準(zhǔn)確度的關(guān)鍵,調(diào)整成其他需要的時(shí)間即可,例如2012-12-20等。
if(a.length > 1){
a1 = a[0].split("-");
a2 = a[1].split(":");
EndTime= new Date(a1[0], a1[1] - 1, a1[2], a2[0], a2[1],a2[2]);
}
var NowTime= new Date(NowYear,NowMonth,NowDate,NowHour,NowMinute,NowSecond);
var nMS =EndTime.getTime() - NowTime.getTime();
var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
var dddd= nD+'-'+nH+'-'+nM+'-'+nS;

if(nD>= 0){
document.getElementById('RemainD').innerText = nD;
document.getElementById('RemainH').innerText = nH;
document.getElementById('RemainM').innerText = nM;
document.getElementById('RemainS').innerText = nS;
}else {
document.getElementById('CountMsg').innerText="所有時(shí)間到!";
}
setTimeout("showtime()", 1000);
}
function startclock() {
showtime(); //調(diào)用計(jì)算時(shí)間差方法,并顯示
}
/script>
/head>
body>
div id="CountMsg">
距離結(jié)束還剩font color="red" size=5>strong id="RemainD">XX/strong>天strong id="RemainH">XX/strong>時(shí)strong id="RemainM">XX/strong>分strong id="RemainS">XX/strong>秒/font>
/div>
/body>
/html>
您可能感興趣的文章:
  • javascript同步服務(wù)器時(shí)間和同步倒計(jì)時(shí)小技巧
  • Javascript實(shí)現(xiàn)商品秒殺倒計(jì)時(shí)(時(shí)間與服務(wù)器時(shí)間同步)
  • js 倒計(jì)時(shí)(高效率服務(wù)器時(shí)間同步)

標(biāo)簽:梅州 吳忠 肇慶 白銀 臨沂 南充 黔東 昌都

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《JSP獲取服務(wù)器時(shí)間以倒計(jì)時(shí)的形式在頁面顯示》,本文關(guān)鍵詞  JSP,獲取,服務(wù)器,時(shí)間,以,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《JSP獲取服務(wù)器時(shí)間以倒計(jì)時(shí)的形式在頁面顯示》相關(guān)的同類信息!
  • 本頁收集關(guān)于JSP獲取服務(wù)器時(shí)間以倒計(jì)時(shí)的形式在頁面顯示的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章