Clock

Clock
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Clock</title> <style> body { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; background-color: #282c34; color: white; font-family: Arial, sans-serif; margin: 0; text-align: center; } .clock { font-size: 5rem; margin-bottom: 20px; } .code { background-color: #333; border: 1px solid #444; padding: 10px; border-radius: 5px; width: 80%; max-width: 800px; overflow-x: auto; } code { display: block; white-space: pre-wrap; font-family: monospace; } </style> </head> <body> <div class="clock" id="clock"></div> <script> function updateClock() { const now = new Date(); const hours = String(now.getHours()).padStart(2, '0'); const minutes = String(now.getMinutes()).padStart(2, '0'); const seconds = String(now.getSeconds()).padStart(2, '0'); document.getElementById('clock').textContent = `${hours}:${minutes}:${seconds}`; } setInterval(updateClock, 1000); updateClock(); // initial call to display clock immediately </script> </body> </html>

Comments

Popular posts from this blog