Forum Academy Marketplace Showcase Pricing Features

Conditional formatting on the basis of current time

Hi,

I have a few elements on my page where I want them to be formatted on the basis of current time.

e.g. If the current time is past start time, something should turn red; Some button should get enabled only when current time is something; If current time is something, corresponding element should get highlighted, etc.

This works fine when the page is loaded. However, when page remains open, those elements’ formatting don’t get updated as time changes.

How do I achieve what I want? I am aware of “Do every 5 seconds” kind of thing. But one I am not sure how it will be on performance, and two, it is very cumbersome to do that. I have to go and put custom state to all those elements and keep updating those. And in repeating group it is even more tricky.

Is there some better way to do it? Or am I doing it incorrectly?

Thanks,
Mukesh

I got an idea that probably I can create a custom state at page level that can hold current time. I can keep updating that one every x seconds, and then all the elements in the page can refer to that instead of current time.

Wonder if there is better method though.

Check out this plugin:

Current date/time Plugin | Bubble

It works like the standard Current Date/Time except it updates in real-time rather than only on page load, so you can run conditional actions and formatting, in real-time, based on the current date/time.

Thanks. Interesting. So indeed there is no way Bubble gives current date/time directly on the page after it has been loaded. Hmm.

Does this plugin do something else too? I may as well use the method of adding custom state to the page and update it every few seconds instead of increasing the size of application by adding another plugin? Just checking out of genuine curiosity.