## 2017년 3월 27일 월요일

### Countdown Timer

Is iit possibile to add an hour to countdown Timer. Because I need to play the lecture and it takes around two hours and half.

--
sure, that's possible

first you should understand, how that example is working
and after that, it should be no problem for you to add a global variable intHoursLeft...
remember: and hour has 60 minutes...

--

--
how many milliseconds are there in 1 hour?

--
alternatively now you also can use the new clock methods
DurationToHours
DurationToMinutes
DurationToSeconds

--
I tried again but it doesn't work. It is very difficult.

--
I tried again but the timer it doesn't move.

--
the second screenshot looks better
after having calculated intHoursLeft, you have to calculate the remaining millis like this
intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

--
I tried to do what have said, but unfortunately, it doesn't work

--
If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...

--
Thank you Taifun for your help.
Please tell me what can I do.

--
this was the correct calculation of the hours

after having calculated intHoursLeft, you have to calculate the remaining millis like this
intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

--
I really appreciate of you support and help.

--
I think, it's important to understand, what you are doing...
therefore let's take an example and let's calculate it manually

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours

then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

--
I have been trying to calculate this equations you had mentioned since yesterday. Now,I understand more than before, but please learn me more.

--
Can you check this calculation if it is more correct?

--

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

after calculation of the hours, where are the remaining milliseconds now in your blocks?

also you forgot to answer these questions
now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

also use Do it to debug your blocks, see tip 4 here

--
Sorry, I can't find the remaining milliseconds in block. but what I know that it is 1842000

--
after having calculated intHoursLeft, you have to calculate the remaining millis like this
intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

--

--
it is YOU who should check the calculation...
and the tool to use is as already said Do it, see tip 4 here

why do you use the LeadingZeros procedure for the remaining milliseconds?

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

you still forgot to answer these questions

now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

1842000 milliseconds
how many minutes do you get? how many seconds do you get?

protip: take a look at the original solution here https://puravidaapps.com/countdown.php

--
1842000 / 60000  = 30 minutes

--
Yes, I have got it now. Thank you Taifun.
But the problem is that the timer doesn't start countdown until become less than one hour.

--
I think, you have to subtract additionally the hours

use Do it to debug your blocks

--
Yes, you are right.
Now is working.
Thank you so much Taifun for your learning me.
I want to know is there an example for count-up instead?

--

is there an example for count-up instead?
I don't know
probably you can find an example after doing a search in the forum?

also what about just trying to build it yourself?
you learned how to count down... to count up should be similar...

--
Can you please give me a hint how to start and I will complete the calculation.

--
I need your help to tell me what can I do to start the calculation in correct way.

--
sorry, I do not have time currently, you might want to try something yourself or someone else might chime in

--
What is the difference between count-up and count-down? Just reverse the numbers and get the difference in time. You know already how to calculate that difference.

--
Thank you Ghica,
I will be happy if you give me an example in reverse of this example for countdown timer :
let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

--