為什么一直顯示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);
? ? //獲取當(dāng)前時間
? ? curShowTimeSeconds=getCurrentShowTimeSeconds();
}
?//獲取當(dāng)前時間
function getCurrentShowTimeSeconds() {
var curTime=new Date();
var ret=endTime.getTime()-curTime.getTime();//得到的是毫秒數(shù)
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;
? ?//繪制小時
2017-02-28
是這么解決的,求解
2016-01-16
已經(jīng)解決;