How to trigger an action when a new day starts

Is there any chance to trigger an action when a new day starts? For example, you have a list of habits that have the status of “Completed”. When a new day starts, it will go back to “Not Completed”. I have tried the “Countdown” component but I cant seem to find the correct equation to say Countdown from Tomorrow -(minus) Current Time. This way it will be somewhat automated and the Countdown will restart every day. Is this the right approach? Any Suggestions?

Thanks in advance.

Hi @jpriesco ,

I find that INT(start of today) is reliable to mark the date.

So you can make collection for that, and have that list on screen you want to show.

Put max 1 on the list and have countdown to check with hidden field if it has changed.

Hey @Yongki ,

Thank you so much for the response. I have tried this but unfortunately is not doing what i need. So when I have INT for 8/15/2021 (today), it gives me the number 18854. What I need is a countdown from seconds in a day (86400) - the current time in seconds. By doing this, each time that the seconds advances, it will get closer to 0 and then restart the countdown because its a new day. I apologize if I was confusing. Does this make sense?

Thank you!

Hi, I have a game, when a user playes 3 times, the game closes the playing possibility and asks the player to comeback in 24 hours to play again,

in my user collection I added: daytask finish? (true/false) and last time played (date value)
when the player plays the 3rd time the replay button updates the users "daytask finish=True/ last played time=cuurent time)

the replay button disapears and a hom button appears to let him go back to the home screen (where the play button disappears too (instead there’s a text asking him to comeback tomorrow)

I set the home screen to update the user : daytask finish = false (with condition : if logged in user > last played time > is before > 1day (here you can put Start of today)

and that’s it, I think that’ll help you a lot

Here’s a link to the game: Tap the cookie
play 3 times and see what happens "I’ve set the time to 5 minutes so you don’t have to wait until tomorrow to see the result (there’s also an update screen button in the up-left side of the screen (to refresh the screen and trigger the User daytask finish property)

Ohh you need to display seconds.

How about like this, start of today + 1 - current time, this should result of fraction that can be multiplied by 86400 for seconds.

But beware that countdown is only active at current screen, if the user move to another, it is reset, unless you add variable that hold the last seconds. I think there is a tutorial about this by @Victor , he is genius about this. :grinning:

But my suggestion to you is just check the difference between current start of today and previous start of today at visit screen if you don’t use list, or if you use list, put countdown inside it and do the checking there, but it needs collection that I mentioned before.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.