0

I have a website in progress and not ready yet.I have a welcome page where i want to display a countdown timer until the site is ready.

I'm using countdown.js plugin. and this the script i'm using:

$(document).ready(function() {
"use strict";
$("#countdowncont").countdown({
    date: "30 april 2019 12:00:00", /** Enter new date here **/
    format: "on"
},
function() {
    // callback function
});
});

In the days span i always get "24days" no matter what the date is!!

Youssef Boudaya
  • 123
  • 1
  • 2
  • 15

2 Answers2

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}
Dheeraj kumar Rao
  • 8,132
  • 3
  • 22
  • 24
0

Try this::

   $(document).ready(function () {
        "use strict";
        $('#countdowncont').countdown('2019/04/30', function (event) {
        $(this).html(event.strftime('%w weeks %d days %H:%M:%S'));
    });
    });