我的代码: var clock;
$(document).ready(function (){
var nDate = new Date(2015, 01, 15, 18);
var currentDate = new Date();
var diff = (nDate.getTime() / 1000) - (currentDate.getTime() / 1000);
clock = $('.n-clock').FlipClock(diff, {
clockFace: 'DailyCounter',
autoStart: true,
countdown: true
});
});
我做数学错了吗?如果是这样,请告诉我什么是错的。
答案 0 :(得分:2)
月份从零开始编号,因此以下
var nDate = new Date(2015, 01, 15, 18);
2月 15日。
解决此问题后,结果是正确的。在Chrome中:
> var nDate = new Date(2015, 0, 15, 18);
> var currentDate = new Date();
> var diff = (nDate.getTime() / 1000) - (currentDate.getTime() / 1000);
> diff / 24. / 3600.
< 2.894391319445438
(即不到三天之后。)