var str = location.href; if (str.includes('index.html') && ((h == 20 && m >18) || h > 21) && h <= 23) { location = 'index2.html'; }