(function showInventory() { var products = document.querySelector('.products'); var checkTime = setInterval(timer, 1000); products.style.display = 'none'; timer(); function timer() { var date = new Date(); var dayOfWeek = date.getDay(); var hour = date.getHours(); var minutes = date.getMinutes(); console.log(date); if (dayOfWeek !== 4 || dayOfWeek === 4 && hour <= 19 && minutes < 50) { console.log('timer not running'); clearInterval(checkTime); } else if (dayOfWeek === 4 && hour >= 20) { products.style.display = 'initial'; clearInterval(checkTime); console.log('showing product'); } } }());