Countdown Timer / Animate CC html5 Canvas
Hello,
Does anybody know how to make a dynamic countdown timer to a future date (Jan 1 2020) displaying by Days : Hours : Minutes : Seconds?
Any help would be much appreciated.
Thanks,
Charlie
Hello,
Does anybody know how to make a dynamic countdown timer to a future date (Jan 1 2020) displaying by Days : Hours : Minutes : Seconds?
Any help would be much appreciated.
Thanks,
Charlie
Hi Klaus,
Thank you for the great details. That got me going in the right direction.
I found this and works perfect:
var book_release_date = new Date(2019,6,1); // for july, not june, 1st 2019 release date.
createjs.Ticker.addEventListener('tick',tickF.bind(this))
function tickF(e){
this.tf.text = formatF(book_release_date.getTime()-new Date().getTime());
}
function formatF(ms){
var days = Math.floor(ms/(1000*60*60*24));
ms -= days*1000*60*60*24;
var hours = Math.floor(ms/(1000*60*60));
ms -= hours*1000*60*60
var min = Math.floor(ms/(1000*60));
ms -= min*1000*60;
var sec = Math.floor(ms/1000);
return ' '+padF(days)+' '+padF(hours)+' '+padF(min)+' '+padF(sec);
}
function padF(n){
var s=n.toString();
while(s.length<2){
s='0'+s;
}
return s;
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.