Functionality activated once a day

Hi everybody,

So here I would like to have a feature that activates only once a day, I explain, for example, I would like that we can pressing a button “sent a heart” on the profile of another user but we can not click at infinity! That is, we can send a heart once a day!

I do not know how to do … Thanks for the help!

hello, it is easy, you have to make some date variable:

public HeartClickDate: Date;

and let’s say clicking on heart triggers event like this one:

 if(this.HeartClickDate != null && 
HeartClickDate.getYear() != new Date().getYear() && 
HeartClickDate.getMonth() != new Date().getMonth() && 
HeartClickDate.getDate() != new Date().getDate())
//here goes some function that makes the heart clicked
this.HeartClickDate = new Date();

or you can disable this heart button using similiar logic but with [disabled] flag on button

1 Like

Thank you for your answer ! I’ll try this, I’ll come back to say if I’m successful! :slight_smile: Thank you !