ASP实现倒计时功能
mskaishi="2012-2-21-12-10-00"?'秒殺開始
msjieshu="2012-2-22-12-11-00"?'結束時間??????????
dqshijian=replace(date() ,"/","-")&"-"&replace(time(),":","-") '當前時間
'response.Write("現在時間是: "&dqshijian)
'response.Write("<BR>秒殺開始時間是"&mskaishi&"<br>秒殺結束時間是"&msjieshu)
kaishi=split(mskaishi,"-")
jieshu=split(msjieshu,"-")
dangqian=split(dqshijian,"-")
a0=kaishi(0)-dangqian(0) '年? 距離開始 <1時候成立
a1=kaishi(1)-dangqian(1) '月? 距離開始
a2=kaishi(2)-dangqian(2) '日? 距離開始
a3=kaishi(3)-dangqian(3) '時? 距離開始
a4=kaishi(4)-dangqian(4) '分? 距離開始
a5=kaishi(5)-dangqian(5) '秒? 距離開始
b0=jieshu(0)-dangqian(0) '年? 距離結束 】>-1成立
b1=jieshu(1)-dangqian(1) '月? 距離結束 】
b2=jieshu(2)-dangqian(2) '日? 距離結束 】
b3=jieshu(3)-dangqian(3) '時? 距離結束 】
b4=jieshu(4)-dangqian(4) '分? 距離結束 】
b5=jieshu(5)-dangqian(5) '秒? 距離結束 】
'response.Write("<br>--------------------------------------------------------------<br>")
fengyu=fengyu+" "
julikaishishijian=+(a0*365*30*24*60*600+a1*30*24*60*60+a2*24*60*60+a3*60*60+a4*60+a5)
julijieshushijian=+(b0*365*30*24*60*600+b1*30*24*60*60+b2*24*60*60+b3*60*60+b4*60+b5)
if julikaishishijian<1 then
?if julijieshushijian>-1 then
?'response.Write("已經開始啦<br>距離開始有"&TimeToData(-julikaishishijian)&"秒")
?'response.Write("<br>距離結束時間還有"&TimeToData(julijieshushijian))
?%>
?? <!---- <DIV id="time"></DIV>----->
<%fengyu=fengyu+"<DIV id='sheng"&zhaoyingjie&"'></DIV>"%>
??? <%
?else
?fengyu=fengyu+"結束了"&vbcrlf
?end if
else
?fengyu=fengyu+"還沒有開始"&vbcrlf
?'response.Write("還沒有開始呢距離開始有"&TimeToData(julikaishishijian))
end if
'response.Write("<br>距離開始還有"&kaishi(0)-dangqian(0)&"年")
'for i=0 to ubound(kaishi)
'response.write mystr(i)
'next
'response.end
fengyu=fengyu+vbcrlf+"<SCRIPT LANGUAGE="&chr(34)&"JavaScript"&chr(34)&">"&vbcrlf
fengyu=fengyu+"function time() " &vbcrlf
fengyu=fengyu+"{? "&vbcrlf
fengyu=fengyu+"var now,h,m,s; " &vbcrlf
fengyu=fengyu+"now=new Date();? "&vbcrlf
fengyu=fengyu+"h = now.getHours(); " &vbcrlf
fengyu=fengyu+"m =now.getMinutes(); " &vbcrlf
fengyu=fengyu+"s = now.getSeconds();? "&vbcrlf
fengyu=fengyu+"if(h<10) h="&chr(34)&"0"&chr(34)&"+h;? "&vbcrlf
fengyu=fengyu+"if(m<10) m="&chr(34)&"0"&chr(34)&"+m;? "&vbcrlf
fengyu=fengyu+"if(s<10) s="&chr(34)&"0"&chr(34)&"+s;? "&vbcrlf
fengyu=fengyu+"setTimeout("&chr(34)&"time();"&chr(34)&", 1000);? "&vbcrlf
fengyu=fengyu+"}? "&vbcrlf
fengyu=fengyu+"time();"&vbcrlf
fengyu=fengyu+"var strm"&zhaoyingjie&"="&chr(34)&""&msjieshu&""&chr(34)&";"&vbcrlf
fengyu=fengyu+"function timem"&zhaoyingjie&"()? "&vbcrlf
fengyu=fengyu+"{"&vbcrlf
fengyu=fengyu+"var arr"&zhaoyingjie&"=strm"&zhaoyingjie&".split("&chr(34)&"-"&chr(34)&"); " &vbcrlf
fengyu=fengyu+"var now"&zhaoyingjie&"=new Date(arr"&zhaoyingjie&"[0],arr"&zhaoyingjie&"[1],arr"&zhaoyingjie&"[2],arr"&zhaoyingjie&"[3],arr"&zhaoyingjie&"[4],arr"&zhaoyingjie&"[5]); "&vbcrlf
?
fengyu=fengyu+"var now=new Date(); "&vbcrlf
fengyu=fengyu+"var h,m,s,dif;"&vbcrlf
fengyu=fengyu+"now.setMonth(now.getMonth()+1);"&vbcrlf
fengyu=fengyu+"dif= now"&zhaoyingjie&".getTime()-now.getTime(); "&vbcrlf
fengyu=fengyu+"h = dif / (60 * 60 * 1000); "&vbcrlf
fengyu=fengyu+"m = (dif % (60 * 60 * 1000))/(60 * 1000);"&vbcrlf
fengyu=fengyu+"s = ((dif % (60 * 60 * 1000))%(60 * 1000))/1000;"&vbcrlf
fengyu=fengyu+"if(dif>0)"&vbcrlf
fengyu=fengyu+"{"&vbcrlf
fengyu=fengyu+" document.getElementById("&chr(34)&"sheng"&zhaoyingjie&""&chr(34)&").innerHTML="&chr(34)&"剩余<span>"&chr(34)&"+ parseInt(h) + "&chr(34)&"</span>小時<span>"&chr(34)&" + parseInt(m) + "&chr(34)&"</span>分<span>"&chr(34)&"+parseInt(s)+"&chr(34)&"</span>秒"&chr(34)&";? "&vbcrlf
fengyu=fengyu+" setTimeout("&chr(34)&"timem"&zhaoyingjie&"()"&chr(34)&", 1000); "&vbcrlf
fengyu=fengyu+"}"&vbcrlf
fengyu=fengyu+"else"&vbcrlf
fengyu=fengyu+"{"&vbcrlf
fengyu=fengyu+" document.getElementById("&chr(34)&"sheng"&zhaoyingjie&""&chr(34)&").innerHTML="&chr(34)&"秒殺結束"&chr(34)&";"&vbcrlf
fengyu=fengyu+"}"&vbcrlf
fengyu=fengyu+"} "&vbcrlf
fengyu=fengyu+"</SCRIPT>"&vbcrlf
fengyu=fengyu+"<script language="&chr(34)&"javascript"&chr(34)&">timem"&zhaoyingjie&"();</script> "&vbcrlf
'response.Write(fengyu)
總結
以上是生活随笔為你收集整理的ASP实现倒计时功能的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dB、dBm、dBw的含义和转化关系
- 下一篇: jenkins+maven+jmeter