import {useEffect, useState} from 'react'; /** "실시간 업데이트: 오후 4:41:56" 표시. 1초마다 갱신된다. */ export function LiveClock() { const [clock, setClock] = useState(''); useEffect(() => { const update = () => { const now = new Date(); const period = now.getHours() >= 12 ? '오후' : '오전'; const hours = now.getHours() % 12 || 12; const minutes = String(now.getMinutes()).padStart(2, '0'); const seconds = String(now.getSeconds()).padStart(2, '0'); setClock(`${period} ${hours}:${minutes}:${seconds}`); }; update(); const timer = setInterval(update, 1000); return () => clearInterval(timer); }, []); return ( 실시간 업데이트: {clock} ); }