var hourtime=prompt("输入下班时间,如下: ","17:30:00");
function displayTime() {
var elt = document.getElementById("clock");
var elt2 = document.getElementById("todaydatetime");
if(leftTime < 0)
{
elt.innerHTML = "Over";
}
else
{
//var endTime = new Date("2016/12/30 17:30:00");
var endTime =new Date(new Date().toLocaleDateString()+" "+hourtime);
var now = new Date();
var nowYear=now.getFullYear();
var nowMonth=now.getMonth()+1;
var nowDay=now.getDate();
var leftTime = endTime.getTime() - now.getTime();
var ms = parseInt(leftTime % 1000).toString();
leftTime = parseInt(leftTime / 1000);
var o = Math.floor(leftTime / 3600);
var d = Math.floor(o / 24);
var m = Math.floor(leftTime / 60 % 60);
var s = leftTime % 60;
elt2.innerHTML = nowYear + " 年 " + nowMonth + " 月 " + nowDay + " 日 ";
//elt.innerHTML = nowYear + " 年 " + nowMonth + " 月 " + nowDay + " 日 " + o + "小时:" + m + "分:" + s + "秒:" + ms.charAt(0);
elt.innerHTML =o + "小时:" + m + "分:" + s + "秒:" + ms.charAt(0);
setTimeout(displayTime, 100);
}
}
displayTime();