import { useState, useEffect } from 'react'; import '../style/Clock.css'; function Clock() { const [now, setNow] = useState(new Date()); useEffect(() => { const timer = setInterval(() => setNow(new Date()), 1000); return () => clearInterval(timer); }, []); const time = now.toLocaleTimeString('en-GB'); // HH:MM:SS const date = now.toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric' }); return (
{time} {date}
); } export default Clock;