Only Show Component if it’s the First Week of the Month

This is a solution to hide your component unless it is the first day of the month.

  • Not yet re-checked
  • Classic builder

Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

Screenshot for “Only Show Component if it’s the First Week of the Month”

This is a solution to hide your component unless it is the first day of the month.

One Easy Step

Add the following code to the JavaScript tab of the page.

Text
Date.prototype.getWeekOfMonth = function() {
  var firstWeekday = new Date(this.getFullYear(), this.getMonth(), 1).getDay();
  var offsetDate = this.getDate() + firstWeekday - 1;
  return Math.floor(offsetDate / 7);
};

TB.render('component_ID', function(data) {
    if(new Date().getWeekOfMonth() !== 0){
        data.ele.css('display','none');
    }
    
});
Screenshot for “Only Show Component if it’s the First Week of the Month”
Screenshot for “Only Show Component if it’s the First Week of the Month”

Original Community Post:

Only show component if it's the first week of the month - Community Discussions / Tips and Tricks - Tadabase Community

Was this page helpful?

Something wrong or missing on this page? Tell us.