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.
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');
}
});
Remember to edit the component ID in the code above to match your component's ID. This can be found in the image below.
We'd love to hear your feedback.