<script language="javascript" type="text/javascript">
var Time;
var MyServerTime;
$(function() {
GetServerTime();
});
//获得服务器时间和设置当前期号
function GetServerTime() {
var rand = Math.random();
$.get("getservertime/getime.aspx?radn=" + rand, { Action: "get", Name: "lulu" }, function(data, textStatus) {
this;
NowServerTime(data);
});
}
function NowServerTime(data) {
Time = data;
ServerTimeCode();
}
function ServerTimeCode() {
var Rowdata = "2009-6-12 20:50:00"
var ServerTime = new Date(Date.parse(Time.replace(/-/g, "/")));
var NowTime = new Date(Date.parse(Rowdata.replace(/-/g, "/")));
MyServerTime = NowTime - ServerTime;
alert(MyServerTime);
Delete();
}
function Delete() {
MyServerTime--;
var nH = Math.floor(MyServerTime / (1000 * 60 * 60)) % 24; //得到多少小时
var nM = Math.floor(MyServerTime / (1000 * 60)) % 60; //得到多少分钟
var nS = Math.floor(MyServerTime / 1000) % 60; //得到多少秒
var strTime = "";
if (MyServerTime > 0) {
if (nH >= 10) {
strTime = strTime + nH;
}
else {
strTime = strTime + "0" + nH;
}
if (nM >= 10) {
strTime = strTime + ":" + nM;
}
else {
strTime = strTime + ":0" + nM;
}
if (nS >= 10) {
strTime = strTime + ":" + nS;
}
else {
strTime = strTime + ":0" + nS;
}
$("#divTime").html(strTime);
}
else {
alert("时间到!");
}
setTimeout(Delete, 1000);
}
我这样写 时间是出来了 但是秒不能动!高手帮我看看 我要实现服务器倒计时