<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title> New Document </title> <meta name="Generator" content="EditPlus"> <meta name="Author" content="DAYU"> <meta name="Keywords" content=""> <meta name="Description" content=""> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></scrip> </head> <body> <?php //3天后的时间 $d =strtotime('+1 days'); $threeday=date('Y-m-d H:i:s',$d); ?> <span id="id1" style="display:none;"><?=$threeday;?></span> <label id="showLeft">这里显示剩余时间</label> <script> var dt = $("#id1").text(); var strArr = dt.split(" "); var strDay = strArr[0].split("-"); var strTime = strArr[1].split(":"); //document.write(strDay[0]+strDay[1]+strDay[2]+strTime[0]+strTime[1]+strTime[2]); //这个函数是倒计时 function djs(){ minutes = 1000 * 60; hours = minutes * 60; days = hours * 24; //var years = days * 365; date1 = new Date(); date2 = new Date(Date.UTC(strDay[0], strDay[1]-1, strDay[2], strTime[0]-8, strTime[1], strTime[2])); minudt = date2 - date1; //var y = Math.floor(minudt/years); d = Math.floor(minudt/days); h = Math.floor((minudt - d * days)/hours); m = Math.floor((minudt - d * days - h * hours)/minutes); s = Math.floor((minudt - d * days - h * hours - m * minutes)/1000); document.getElementById("showLeft").innerHTML=d + "天" + h + "时" + m + "分" + s + "秒"; //document.all.showLeft.innerHTML=d + "天" + h + "时" + m + "分" + s + "秒"; setInterval("djs()",1000); } djs();//占CPU </script> </body> </html>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。