I am playing with jQuery and am stuck at a Countdown timer. So far it was working well. But when I am running the Website, it's showing all the time as 0.
Here is my Code:
var now = new Date();
var end = new Date('03/15/2016 10:00:00 PM');
var remaining = end - now;
var countTo = remaining.valueOf();
// var countTo = 25 * 24 * 60 * 60 * 1000 + now.valueOf();
alert(countTo);
$('.timer').countdown(countTo, function(event) {
$(this).find('.days').text(event.offset.totalDays);
$(this).find('.hours').text(event.offset.hours);
$(this).find('.minutes').text(event.offset.minutes);
$(this).find('.seconds').text(event.offset.seconds);
});
When I use the commented countTo, the whole thing works. And as both countTo returns TimeStamp, I am not understanding why it is not working. Any help will be very helpful. Thanks in advance.
Found the solution myself after waiting for others. Adding now with the remaining did the trick for me.
var now = new Date();
var end = new Date('03/15/2016 10:00:00 PM');
var remaining = end - now;
var countTo = remaining.valueOf() + now.valueOf();
alert(remaining);
$('.timer').countdown(countTo, function(event) {
$(this).find('.days').text(event.offset.totalDays);
$(this).find('.hours').text(event.offset.hours);
$(this).find('.minutes').text(event.offset.minutes);
$(this).find('.seconds').text(event.offset.seconds);
});
Thanks.