Well, since you've mentioned FlipClock, I guess this should work:
Calculate difference between current date and your desired date:
var date1 = new Date("8/24/2012");
var date2 = new Date();
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffSeconds = Math.ceil(timeDiff / 1000);
Create FlipClock (it counts up by default, to change that set countdown: true):
var clock = $('.your-clock').FlipClock({
// ... your options here
});
Use setTime()
method to set time:
clock.setTime(diffSeconds);
Now just start the clock:
clock.start();
I haven't checked this, but should work according to documentation.
Edit:
Since FlipClock doesn't support nothing beyond 99 days, here is another approach with Countdown.js:
setInterval(function() {
var timespan = countdown(new Date("08/24/2012"), new Date());
var div = document.getElementById('time');
div.innerHTML = "Time difference with 08/24/2012 is " + timespan.years + " years, " + timespan.months + " months, " + timespan.days + " days, " + timespan.hours + " hours, " + timespan.minutes + " minutes, " + timespan.seconds + " seconds."
}, 1000);
See demo.