<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<script type="text/javascript">
window.onload=function(){
showTime();
shengqiang();
function checktime(i){
if(i<10){
i="0"+i;
}
return i;
}
function showTime(){
var mydate=new Date();
var myyear=mydate.getFullYear();
var mymonth=mydate.getMonth()+1;
var myday=mydate.getDate();
var week=["星期日","星期一","星期二","星期三","","星期四","星期五","星期六"];
var today=mydate.getDay();
var myweek=week[today];
var myhours=mydate.getHours();
var myminu=mydate.getMinutes();
var mysecond=mydate.getSeconds();
myhousr=checktime(myhours);
myminu=checktime(myminu);
mysecond=checktime(mysecond);
var lefttime=myyear+"年"+mymonth+"月"+myday+"日"+" "+myweek+" "+myhours+":"+myminu+":"+mysecond;
document.getElementById("a").innerHTML=lefttime;
setTimeout(showTime,500)
}
var nowtime=new Date();
var lefttime=new Date("2016,01,01");//设定时间要加双引号
var d_valuetime=(lefttime.getTime()-nowtime.getTime())/(24*60*60*1000);
var d_days=Math.ceil(d_valuetime);
document.getElementById("b").innerHTML=d_days;
function shengqiang(){
var qgou=new Date("2015/12/23,20:27:00");
var xianzai=new Date()
var Lefttime=parseInt((qgou.getTime()-xianzai.getTime())/1000);//换算成秒
var days=parseInt(Lefttime/(24*60*60));
var hour=parseInt(Lefttime/(60*60)%24);
var minute=parseInt(Lefttime/60%60);
var second=parseInt(Lefttime%60);
var shengTime=days+"天"+hour+"小时"+minute+"分"+second+"秒";
document.getElementById("c").innerHTML=shengTime;
setTimeout(shengqiang,500);
if(shengse<=0){
document.getElementById("c").innerHTML="团购已经结束";
}
}
}
</script>
<body>
计时:<span id="a">a</span></body><br/><br/>
倒计时,距2016年还剩:<span id="b">b</span><br/><br/>
限时抢:<span id="c">c</span>
</script>
</body>
</html>