Files
Portfolio/app/components/Clock.tsx
2026-01-22 20:55:07 +00:00

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>;
}