function updateClock() { const now = new Date(); let hours = now.getHours(); let minutes = now.getMinutes(); let seconds = now.getSeconds(); // Rounding to the nearest 5 minutes minutes = Math.round(minutes / 5) * 5; if (minutes === 60) { minutes = 0; hours++; if (hours === 24) { hours = 0; } } // Formatting to display as HH:MM const timeString = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`; // Displaying the rounded time document.getElementById('clock').textContent = timeString; } // Update the clock every minute setInterval(updateClock, 60000); // Initial update updateClock();