Continuously update displayed time?

Hi - I’ve built an app that displays the current time in the title bar. The time is populated in the title bar content via a formula:

FORMAT_DATETIME_LOCAL(NOW(), "HH:mm")

However, once the page is rendered and the current time is displayed, the displayed time doesn’t update as time passes. So the system clock will move on, but the displayed time remains frozen to the time when the page loaded.

I know that component values update as underlying data changes, but NOW() doesn’t seem to trigger the same event.

How best to get the displayed time to continue to update once the page is mounted and has focus?

Thx!
Chris

We should probably implement a native functionality for something like “re-evaluate formula every N milliseconds”… Will have to think about this.

Now, what you can do is add an appVars.timeNow app variable, and on global canvas, add a loop that starts on App launched event, then e.g. every 1000 ms runs Set app variable with NOW(). Then you can use

FORMAT_DATETIME_LOCAL(appVars.timeNow, "HH:mm")

See the screenshot below for the setup on global canvas!

1 Like

This worked well, thank you!