Tomas Alonso Rehor Tomas Alonso Rehor - 5 months ago 21
Javascript Question

Simple Jquery Countdown

Hello I have a very simple problem but official documentation and online help wasnt enough to help me with this.

I have this template countdown that counts days remaining for new year.

I just want to change it so it counts to October the 1st of 2016...

var PageComingSoon = function () {
return {
//Coming Soon
initPageComingSoon: function () {
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#defaultCountdown').countdown({until: newYear})
}
};
}();

Answer

The first three parameters of are Date(year, month, day, ...). The given code newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1) clearly states that the year is next year, then the first month, and the first day (note months start at 0). You likely can simply change the values of these to represent October the 1st of 2016.

var myDate = new Date(2016, 9, 1);