为什么一直显示00:00:00
const endTime=new Date(2016,0,17,18,12,12);
var curShowTimeSeconds=0;
//加载页面
window.onload=function(){
var canvas=document.getElementById('canvas');
var context=canvas.getContext('2d');
canvas.width=WINDOW_WIDTH;
canvas.height=WINDOW_HEIGHT;
//绘制canvas画布
render(context);
//获取当前时间
curShowTimeSeconds=getCurrentShowTimeSeconds();
}
//获取当前时间
function getCurrentShowTimeSeconds() {
var curTime=new Date();
var ret=endTime.getTime()-curTime.getTime();//得到的是毫秒数
ret=Math.round(ret/1000);
return ret>0?ret:0;
}
function render(ctx){
//绘制时钟
var hours=parseInt(curShowTimeSeconds/3600);
var minutes=parseInt((curShowTimeSeconds-hours*3600)/60);
var seconds=curShowTimeSeconds-hours*3600-minutes*60;
//绘制小时