Did you ever had a requirement where you need to display a clock which automatically keeps on ticking and shows the current time of the user?
If the answer is YES and then this blog might help. Today we are going to create a digital clock in Canvas apps. Not a very common requirement but if this comes to your plate, you will find this helpful.
So let’s get started. To create a clock, the first thing we need is a timer control. The Timer control should display for each second. So we set the Duration property to 1000.
After every 1 second, the timer will end and restart. In the OnTimerEnd event I write the following formula.
Set(timeNow, Now())
Here I set a variable to the current time. The next thing is to make sure the time automatically start after every second. So I set the AutoStart property to true and Repeat property to true.
We are almost done here. The final step is to set the Text property of the timer. How you want to display the clock time is up to you.
In my case I just want to display the time part. Hence I set the Text property to the below formula.
Text(timeNow, DateTimeFormat.LongTime)
And finally when I run, below is the behavior.
Hope this helped!
You will also like the below posts.
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.