gpt4 book ai didi

javascript - 更改 Flipclock.js 中的日期

转载 作者:行者123 更新时间:2023-12-01 02:29:08 26 4
gpt4 key购买 nike

我需要 Flipclock.js 方面的帮助,我对 Jquery 一无所知,这个插件快把我逼疯了。我只需要将日期更改为 2014 年 11 月 23 日下午 6 点,但我似乎无法弄清楚这一点。

这是我的代码

var clock;
$(document).ready(function() {
// Grab the current date
var currentDate = new Date();

// Set some date in the future. In this case, it's always Jan 1
var futureDate = new Date(currentDate.getFullYear() + 1, 0, 1);

// Calculate the difference in seconds between the future and current date
var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;

// Instantiate a coutdown FlipClock
clock = $('.clock').FlipClock(diff, {
clockFace: 'DailyCounter',
countdown: true
});
});

最佳答案

您设置“futureDate”而不是添加 1 年时使用以下方法设置完成时间:

新日期(年、月、日、时、分、秒、毫秒);

mdn documentation for date

var clock; 
$(document).ready(function() {
// Grab the current date
var currentDate = new Date();
// Set some date in the future. ***change to desired date***
//var futureDate = new Date(2014, 11, 23, 6, 0, 0);
var futureDate = new Date(2014, 10, 23, 18, 0, 0); //fixed as per comments
// Calculate the difference in seconds between the future and current date
var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
// Instantiate a coutdown FlipClock
clock = $('.clock').FlipClock(diff, { clockFace: 'DailyCounter', countdown: true });
});

关于javascript - 更改 Flipclock.js 中的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25686505/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com