在这个倒计时功能中,我在哪里更改日期

Where do I change the date in this countdown function?

本文关键字:在哪里 日期 倒计时 功能      更新时间:2023-09-26

我刚刚下载了这个倒计时脚本(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();
});

也许倒计时日期。。。默认情况下,它是用现在+30天构建的?你可以改变这个。

重要部分是:

setupCountdownTimer( countdownDate );
spaceParallax();
hideIphoneBar();
$("[placeholder]").togglePlaceholder();
setupSignupForm();
});

您的代码本身告诉如何做到这一点:

// 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 );