Hello AI2-friends,
I have been “tinkering” a function with the App Inventor for days now and am not able to reach my goal.
I want to calculate the running time in months, days, hours, minutes between two events.
Example:
After pressing the “Start” button, the current date + time is saved in Tiny-DB Tag “x”.
I press the “Stop” button later and the current date + time is saved in Tiny-Db Tag “y”.
After pressing the “Calculate” button, I would like to display the running time of the event in months, days, hours, minutes and save it in Tiny-DB Tag “Z”.
Could someone give a tip on how I can best do this?
Hi and many thanks for reply,
a. in the the screen we have only a button (or a global-variabel) and not a datepicker or time-picker.
b. in the block of date-picker are not the hours and minutes we need for the duration-calculation.
Is that the right solution for me with the date picker?
Do you have an example APK, that I can convert myself?
Sorry, I’m still a beginner …but it’s a lot of fun with the AI2
Well, what you are returning for each time duration is “correct”, but you are getting the total shown for each one.
You will have to do some more work on the calculations to work out the days, then remove that amount, then the hours, remove that amount, then the minutes.
If you look at Taifun’s example in the link I provided above, he shows how to do this using milliseconds, and the quotient/remainder maths blocks