Copy Code code as follows:
<%@ page language= "java" import= "java.util.*"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<%@ 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 ();
Get service-side time
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} '//Get the end or start time in the database, and then start calculating how long it is before the start or end
Nowsecond = (parseint (nowsecond) +1);
//-------------------------------------------------------------------
var A, a1, A2;
var Endtime;
A = Unescape (' ${enddate} '). Split (""); This is a note, this sentence is the key to the accuracy of the countdown, adjusted to other required time, such as 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= "All the time!" ";
}
SetTimeout ("Showtime ()", 1000);
}
function Startclock () {
Showtime (); Call the calculation time difference method and display
}
</script>
<body>
<div id= "Countmsg" >
The distance ends with <font color= "Red" Size=5><strong id= "Remaind" >XX</strong> day <strong id= "Remainh" >xx </strong> <strong id= "remainm" >XX</strong> <strong id= "remains" >XX</strong> sec </ Font>
</div>
</body>