Adding seconds to the stop watch while its running

hi all i made a stop watch app i want to add seconds to the stop watch while it is running like there will be 2 buttons named 1 and 10 seconds respectively if the user clicks the 1 second button 1 second should be added to the stopwatch and if the user presses 10 second button 10 seconds should be added to the stopwatch

so in the numbers if the user clicks the numbers (1 to 10) that many seconds should be added to the stop watch..
can it be done like this in the last section(of the block page pic) can we check if the button is pressed we can add the last section and the respective seconds by using the add block?

you might want to use the AddSeconds method form the Clock component...
see the documentation here Sensors


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

can you please say how to use that block im not a pro like anybody im just a one step above beginer

please try something... everything you need to know is explained in the documentation...
and if you get stuck, post a screenshot of your updated relevant blocks...

AddSeconds( instant , quantity )

Returns an instant in time some seconds after the given instant.

for example the instant in time could be the Clock.Now block and the quantity could be 10


thank you im confused what should come at instant now i got cleared

what about trying something?
as already said

see also tip 2 here App Inventor: How to Learn | Pura Vida Apps

see also again the documentation to understand what is an instant...

Operations on dates and times, such as from DatePicker and TimePicker , are accomplished through methods in Clock. Date and Time are represented as InstantInTime and Duration.

Instants are assumed to be in the device’s local time zone. When they are converted to or from milliseconds, the milliseconds for a given Instance are calculated from January 1, 1970 in UTC (Greenwich Mean Time).


i know how to use that block the thing is i dont to use in that case..
if you know please tell me

hi! can you say me the solution for my problem I already asked but i didnt get proper answer from the article you problem is when the user clicks the start button the stopwatch should run it is running perfectly and for example its 10 seconds there will be a number keypad layout which has 1,2,3,4 etc numbers buttons on it so when the user clicks on number 1 button 1 second should be added to the stopwatch like if it is 10 seconds immediately when the user taps the number button it should show 11 seconds and continue like that and when the user presses the number 5 button 5 seconds should be added to stopwatch seconds..

what have you tried?

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

you can see the pics in my post"how to add seconds in running stopwatch"

up to now unfortunately you did not try anything...
you might want to use the AddSeconds method as already mentioned and provide an updated screenshot of your blocks...


i tried myself it is adding thnx!

great to hear
please provide the solution to the problem then…
this community is to help each other…
and your answer can help others with the same issue in future… thank you…


but i have a problem in that when ever i click those buttons it is adding but after a second it returns back to the orginal time

see this video :point_up:

Show your blocks.

in the button click blocks i didnt take a snap of two other button but the function are the same as button N1 and like..
and variable (k1 to k10) it is intialized as blank

This is all you need:

1 Like

Regarding the resetting problem, that stems from the data flow.
The data flows from global start_time, and everything downwards in the Clock Timer derives from that.

So that's what you should adjust:
To add to your time, move the start_time back in time by adding a negative duration to it.

1 Like

@kaushik Ain't it what you wanted?

1 Like

@Anke yes this is the thing i want can you say instead of 3 buttons(5,8,10) how to keep 10 buttons(1 to 10)..also in designer page only a label , start btn , stp btn , numbers btn and only clock component in needed right or anything should be added?
by the way thanks for solving my problem