<script type="text/javascript">
window.onload=function(){
var myspan=document.getElementById("myspan");
var datas = Math.ceil((new Date(" 2019/06/21 13:07:00")).getTime()/1000);//定义时间戳
var aaa = Math.ceil(new Date().getTime()/1000); //获取当前时间
console.log('datas==>>', datas)
console.log('aaa==>>', aaa)
var timer=datas - aaa;/*倒计时的秒数*/
var flag;
function daojishi(){
timer=timer-1;/*每一秒钟减一秒*/
myspan.innerHTML=timer;
if(timer==0){
location.href="http://www.baidu.com";/*所要跳转到的网址*/
clearInterval(flag);/*清除循环*/
}
}
flag=setInterval(daojishi,1000);/*每一秒执行一次该函数*/
}
</script>