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)

你可能感兴趣的:(Date,asp,div)