function updateTimeAndDate() { const now = new Date(); let hours = now.getHours(); const minutes = now.getMinutes().toString().padStart(2, '0'); let amPm = hours >= 12 ? 'PM' : 'AM'; if (hours > 12) { hours -= 12; } else if (hours === 0) { hours = 12; } let timeStr = hours.toString().padStart(2, '0') + minutes; if (timeStr.startsWith('0')) { timeStr = ' ' + timeStr.slice(1); } let month = (now.getMonth() + 1).toString().padStart(2, '0'); let day = now.getDate().toString().padStart(2, '0'); const year = now.getFullYear().toString().slice(-2); if (month.startsWith('0')) { month = ' ' + month.slice(1); } if (day.startsWith('0')) { day = ' ' + day.slice(1); } const displayStr = timeStr + amPm + month + day + year; for (let i = 0; i < 12; i++) { document.getElementById('char' + i + '1').textContent = displayStr[i]; document.getElementById('char' + i + '2').textContent = displayStr[i]; } } updateTimeAndDate(); setInterval(updateTimeAndDate, 60000);