<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<button id="bt1" onclick="cont()">开始倒计时</button>
</body>
<script type="text/javascript">
// var times = 1600247268*1000;
// var now = new Date(times);
// console.log(now);
// var year = now.getFullYear();
// var month = now.getMonth();
// var date = now.getDate();
// var hours = now.getHours();
// var mint = now.getMinutes();
// var second = now.getSeconds();
// var day = now.getDay();
// var str = year+"/"+month+"/"+date+" "+hours+":"+mint+":"+second;
// document.write(str+"<br />");
var bt1 = document.getElementById("bt1");
function cont(){
var times = 1600248119*1000;
// var i = 5;
// clearInterval(timer);
var timer=setInterval(function(){
// console.log(now);
var now = new Date(times);
var year = now.getFullYear();
var month = now.getMonth();
var date = now.getDate();
var hours = now.getHours();
var mint = now.getMinutes();
var second = now.getSeconds();
var day = now.getDay();
var str = year+"/"+month+"/"+date+" "+hours+":"+mint+":"+second;
// console.log(i)
// bt1.setAttribute("disabled",false);
times-=1000;
console.log(times);
bt1.innerHTML="倒计时"+str;
// i--;
// if(i<0){
// clearInterval(timer);
// bt1.innerHTML="发送短信";
// bt1.removeAttribute("disabled");
// };
},1000)
};
</script>
</html>
原文:https://www.cnblogs.com/yqqx/p/13680427.html