26 lines
525 B
TypeScript
Executable File
26 lines
525 B
TypeScript
Executable File
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
export function Clock() {
|
|
const [time, setTime] = useState("");
|
|
|
|
useEffect(() => {
|
|
const updateTime = () => {
|
|
const now = new Date();
|
|
setTime(
|
|
now.toLocaleTimeString([], {
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
})
|
|
);
|
|
};
|
|
|
|
updateTime();
|
|
const interval = setInterval(updateTime, 1000);
|
|
return () => clearInterval(interval);
|
|
}, []);
|
|
|
|
return <span>{time}</span>;
|
|
}
|