我有一个正在进行中的网站尚未准备就绪。我有一个欢迎页面,我想在该页面上显示倒数计时器,直到网站准备就绪为止。
我正在使用countdown.js插件。 这是我正在使用的脚本:
$(document).ready(function() {
"use strict";
$("#countdowncont").countdown({
date: "30 april 2019 12:00:00", /** Enter new date here **/
format: "on"
},
function() {
// callback function
});
});
在几天里,无论日期是什么,我总是得到“ 24days”!
答案 0 :(得分:0)
//create a count down timer with own vanilla JS
function countDown(targetDate, targetMonth, targetYear) {
var targetCountDown = targetMonth+ " " + targetDate+ " " + targetYear+ " " + "23:59:59";
var targetCountDown = Date.parse(targetCountDown);
var currntTime = Date.parse(new Date());
var t = targetCountDown - currntTime;
var seconds = Math.floor( (t/1000) % 60 );
var minutes = Math.floor( (t/1000/60) % 60 );
var hours = Math.floor( (t/(1000*60*60)) % 24 );
var days = Math.floor( t/(1000*60*60*24) );
console.log(t);
if(t < 0) { return " 0:0:0 {Sorry Sir, Forgot your past, And go ahead!}" ; }
return {
'total': t,
'days': days,
'hours': hours,
'minutes': minutes,
'seconds': seconds
};
}
console.log(countDown(01,01,2020)); // Format will be DD/MM/YYYY
Output :- {total: 24222070000, days: 280, hours: 8, minutes: 21, seconds: 10}
答案 1 :(得分:0)
尝试一下::
$(document).ready(function () {
"use strict";
$('#countdowncont').countdown('2019/04/30', function (event) {
$(this).html(event.strftime('%w weeks %d days %H:%M:%S'));
});
});