How to change button text dynamicaly based on date?

Hi

I want to implement some sort of double verification on one feature of my app.
To do this, I want to use a button that has different states. Here is what I need :

  1. default, button text is “A”
  2. once clicked, button text is “B”
  3. once clicked more than 20 seconds ago, button text is “C”

I am able to do step 1 and 2 with no issue. How do I do the step 3 in the above?

I’ve tried setting a custom_state (CS) of type date on my button, and used it in the button conditionnal tab. With something like : “CS is not empty and CS+20seconds > current_date”
But it won’t trigger. It seems like the conditions are checked only once when there is an action on the button, and not later on.

Best to you

Schedule a custom event to run 20 seconds after the second click, to set a custom state value.

Thanks, that will work

For my understanding, is the behavior I am experiencing with dates to be expected? What is the general lesson to remember : conditions are not checked temporarily?

Yes, it is… Date objects are static, so you can’t do real-time checks against the current date/time (the current date/time is a static value, set at the moment it was defined).

If you need to check a date against the current date/time in real time, you’ll need to update the value of the current date time every second (or however frequently you need for your use-case).

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.