Show, hide Button by date

Hi there,

I was interested in it, but not sure if it is possible.

I want to add button to my repeater and if the content is uploaded today button will stay shows, but if the content is older than 24hrs than button will hide.

Thanks,
Jakub

You’ll have to determine how old the content is. Then just check it and take the appropriate action (show or hide):

if(content_age < 24) { 
    $w("#button").show();
}
else {
    $w("#button").hide();
}

Good luck,

Yisrael

Hi Jakub,

A database collection has a “hidden” field Date Created (field key: _createdDate):


You can then check that field against today’s date which you get like this:

var today = new Date();

Get the difference between _createdDate and today, and use that in your if statement. You can find a nice discussion on this in the StackOverflow thread Compare two dates with JavaScript.

Yisrael