| This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal. |
| This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal. |
Hi,
Once you click on the button capture the timestamp using Date() and stored to a global variable and set the enabled false to button. On app launch you need to check the global variable is empty or not. If it is not empty use the current time and captured time. Compare difference, if the difference is less than 24 hours then do not enable the button, if the time difference is more than 24 hours then enable the button again to the user.
Hi,
You can achieve this using date object, please try below code snippet on button click, replace alerts with your required action that need to be performed on button click:
storeTime:null,
check24hours:function(){
this.storeTime = kony.store.getItem("time");
var date=new Date();
var presentTime=date.getTime();
if(this.storeTime!==undefined && this.storeTime!==null && this.storeTime!==""){
var diffTime=(presentTime - this.storeTime) / (1000 * 3600 * 24);
if(diffTime >= 1){
alert("button Click action");
kony.store.setItem("time",presentTime);
}
}else{
kony.store.setItem("time",presentTime);
alert("button click action");
}
}
Thanks & Regards