const [time, setTime] = useState(new Date());
useEffect(() => {
const id = setInterval(() => {
setTime(new Date());
}, 1000);
return (() => clearInterval(id))
}, []);
return <p>{time.toLocaleString()}</p>
위 링크로 이동해 보면 포멧으로 1초마다 date가 갱신된다.
.
.
.
.
.
관련 좋은글 참고
https://blog.munilive.com/posts/javascript-localization-with-toLocaleString.html