• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Countdown Timer / Animate CC html5 Canvas

Community Beginner ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

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

Views

6.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Dec 18, 2018 Dec 18, 2018

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

...

Votes

Translate

Translate
Advocate ,
Dec 18, 2018 Dec 18, 2018

Copy link to clipboard

Copied

Charlie

that's a question simple to ask but harder to answer. Because you are targetting HTML5 Canvas to have to get your head around the Javascript Date Object.

Start here: JavaScript Date Reference

And here is a manual to a countdown clock: Build a Countdown Timer in Just 18 Lines of JavaScript — SitePoint

Though it's all not specifically made for AnimateCC Canvas and createJS. You'll have to improvise.

Klaus

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2018 Dec 18, 2018

Copy link to clipboard

Copied

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;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

LATEST

i could not figure out how to have a veriable could you please provide the pictures of the dynamic text

so lame people could use it proper

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2019 Oct 09, 2019

Copy link to clipboard

Copied

This works great! Thanks all. I don't need to display seconds in my timer, just days / hours / minutes - any ideas how I can hide the seconds display?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines