Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

I am using a countdown plugin but I think I am setting the date and time wrong.

This is my code:
 

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(2016,10,27, 10,00,00);

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

    });

});

I am attempting this:

var futureDate = new Date(2016,10,27, 10,00,00);

Which is 27th October 2016 10am.

1 Answer

0 votes
by (13.1k points)

Months in JavaScript are zero-indexed which makes the tenth month November. So, you can do this:

var futureDate = new Date(2016,9,27,10,00,00);

Want to be a full stack developer? Check out the full stack developer course from Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Aug 13, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...