<script type="text/javascript"> var StartTime = new Date("2008/06/15 12:34:03"); document.write("订购时间: " + StartTime.toLocaleDateString() + StartTime.toLocaleTimeString() + "<br/>"); var CurrentTime = new Date(); document.write("当前时间: " + CurrentTime.toLocaleDateString() + CurrentTime.toLocaleTimeString() + "<br/>"); var EndTime=StartTime.getTime() + 15*24*60*60*1000;//约定订购时间15天后关闭交易 EndTime = new Date(EndTime); document.write("结束时间: " + EndTime.toLocaleDateString() + EndTime.toLocaleTimeString() + "<br/>"); var TempTime = StartTime; var nMS,nD,nH,nM,nS; function ShowCloseTime(){ var oDate = new Date(); nMS=EndTime-oDate ; nD=Math.floor(nMS/(1000*60*60*24)); nH=Math.floor(nMS/(1000*60*60)) % 24 ; nM=Math.floor(nMS/(1000*60)) % 60; nS=Math.floor(nMS/1000) % 60; document.getElementById("CloseTime").innerHTML = ("您还有" + nD + "天" + nH + "小时" + nM + "分" + nS + "秒完成交易"); if (nS<0 || nM<0 || nH<0 || nD<0) { document.getElementById("CloseTime").innerHTML = "交易因超过15天,已被系统自动关闭" clearInterval(CloseTimer); } } var CloseTimer = window.setInterval("ShowCloseTime()",1000) </script> <div id="CloseTime"></div>
仿淘宝的交易到计时JS
最新推荐文章于 2020-12-08 12:14:41 发布