Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

RelativeTime.tsx

8 lines352 Bytes

1import { useRelativeTimeState } from "../hooks/useRelativeTimeState";
2​
3// Use a live clock because the compiler caches inline formatting on the timestamp.
4export function RelativeTime(props: { timestamp: string }) {
5 const relative = useRelativeTimeState(props.timestamp);
6 if (relative.status !== "relative") return null;
7 return relative.label;
8}