var hour = new Date().getHours(); // between 7 PM and 7 AM respectively if(hour >= 19 || hour <= 7) { document.body.className += 'between7'; } else { document.body.className += 'notBetween7'; } Copy