Countdown timer to a date in Thunkable
×
Note: To simplify this I have created a countdown extension which you can find here: Countdown extension
You can create a countdown to any date in Thunkable or App Inventor using the code is this exercise to calculate the number of weeks, days, hours, minutes, and seconds to any date.
In this example, I have created a procedure that takes in a StartDate and an EndDate, and returns a list containing the different values that are returned. To calculate the return values I am using the included functions in the clock component to do all the hard work.
There are a variety of reasons you may need a countdown, it could be a countdown to an event, a countdown to a holiday like christmas, or maybe a countdown to a launch date, these blocks will enable you to create apps that can incorporate this feature.
Countdown procedure
StartDate: An Instant that occurs sometime before the EndDate. This can be set to Clock.Now for the current time and date.
EndDate: An Instant that occurs sometime after the StartDate. This can be set to Clock.Now for the current time and date.
Return Values
The procedure returns a list which contains the following values:
- index 1 contains the number of weeks
- index 2 contains the number of days
- index 3 contains the number of hours
- index 4 contains the number of minutes
- index 5 contains the number of seconds
The procedure itself can me modified to meet your needs, for example not everyone would need the week's value, as such this can be removed from the procedure by deleting the relevant blocks of code. Note that if you modify the procedure the indexes for each value will be different from above.
Snapshot of the Countdown procedure |
Countdown Example
You can download the code in the .aia file below which includes an example project that you can play around with to see how it all works.
Download Countdown.aia
Was this helpful?
Comments
Post a Comment