我在哪里更改倒计时功能的日期?

时间:2013-07-31 08:34:08

标签: javascript function countdown

我刚下载了这个倒计时脚本(JavaScript),但我无法弄清楚如何更改计时器倒计时的日期。 原始剧本:

$(function(){
var now = new Date();
// comment out the line below and change the date of your countdown here
var in30Days = new Date( now.getTime() + (30 * 24 * 60 * 60 * 1000) );
// year to countdown to
var countdownYear = in30Days.getFullYear();
// month to countdown to 0 = Jan, 1 = Feb, etc
var countdownMonth = in30Days.getMonth();
// day to countdown to
var countdownDay = in30Days.getDate();

var countdownDate = new Date( countdownYear, countdownMonth, countdownDay );

setupCountdownTimer( countdownDate );

spaceParallax();

hideIphoneBar();

$("[placeholder]").togglePlaceholder();

setupSignupForm();
});

2 个答案:

答案 0 :(得分:0)

也许是countdownDate ...... 默认情况下,它现在建成+ 30天?你可以改变它。

重要的部分是:

setupCountdownTimer( countdownDate );

spaceParallax();

hideIphoneBar();

$("[placeholder]").togglePlaceholder();

setupSignupForm();
});

答案 1 :(得分:0)

您的代码本身告诉如何执行此操作:

// comment out the line below and change the date of your countdown here
var in30Days = new Date( now.getTime() + (30 * 24 * 60 * 60 * 1000) );
// year to countdown to
var countdownYear = in30Days.getFullYear();
// month to countdown to 0 = Jan, 1 = Feb, etc
var countdownMonth = in30Days.getMonth();
// day to countdown to
var countdownDay = in30Days.getDate();

以下行创建countDownDate,将年,月和日传递给函数

var countdownDate = new Date( countdownYear, countdownMonth, countdownDay );

setupCountdownTimer( countdownDate );