# Show, hide Button by date

**URL:** <https://forum.wixstudio.com/t/show-hide-button-by-date/38185>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [April 18, 2018, 11:09am UTC](https://forum.wixstudio.com/t/show-hide-button-by-date/38185 "2018-04-18T11:09:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakub](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jakub/32/1674_2.png) [@jakub](https://forum.wixstudio.com/u/jakub)\
**Post date:** [April 18, 2018, 11:09am UTC](https://forum.wixstudio.com/t/show-hide-button-by-date/38185/1 "2018-04-18T11:09:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [April 18, 2018, 1:23pm UTC](https://forum.wixstudio.com/t/show-hide-button-by-date/38185/2 "2018-04-18T13:23:01Z")

</div>

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

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

```

Good luck,

Yisrael

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [April 18, 2018, 2:23pm UTC](https://forum.wixstudio.com/t/show-hide-button-by-date/38185/3 "2018-04-18T14:23:26Z")

</div>

Hi Jakub,

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

 ![](https://us1.discourse-cdn.com/wix/original/3X/3/9/391cd9d65b462a0024ceba46aa289495b819e7fc.png)

 ![](https://us1.discourse-cdn.com/wix/original/3X/c/6/c6f67b0c41af07e225bd19e369aa72ea8b3bac27.png)  
You can then check that field against today’s date which you get like this:

```javascript
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
